diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2017-07-31 10:48:00 +0100 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2017-07-31 13:36:49 +0100 |
commit | 2535a6716202253df74d8190b028f85cc6d21b72 (patch) | |
tree | 8957f42b7414206a95cfa1719aa11e1b3e2a8638 /compiler/parser | |
parent | c6d4219ae46cddd63aa2b5762efaf99f815009a4 (diff) | |
download | haskell-2535a6716202253df74d8190b028f85cc6d21b72.tar.gz |
Refactoring around FunRhs
* Clarify the comments around the mc_strictness field of FunRhs
* Use record field names consistently for FunRhs
Diffstat (limited to 'compiler/parser')
-rw-r--r-- | compiler/parser/RdrHsSyn.hs | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/compiler/parser/RdrHsSyn.hs b/compiler/parser/RdrHsSyn.hs index f2c8b33000..408da044a9 100644 --- a/compiler/parser/RdrHsSyn.hs +++ b/compiler/parser/RdrHsSyn.hs @@ -514,10 +514,16 @@ mkPatSynMatchGroup (L loc patsyn_name) (L _ decls) = do { unless (name == patsyn_name) $ wrongNameBindingErr loc decl ; match <- case details of - PrefixCon pats -> - return $ Match (FunRhs ln Prefix NoSrcStrict) pats Nothing rhs - InfixCon pat1 pat2 -> - return $ Match (FunRhs ln Infix NoSrcStrict) [pat1, pat2] Nothing rhs + PrefixCon pats -> return $ Match { m_ctxt = ctxt, m_pats = pats + , m_type = Nothing, m_grhss = rhs } + where + ctxt = FunRhs { mc_fun = ln, mc_fixity = Prefix, mc_strictness = NoSrcStrict } + + InfixCon p1 p2 -> return $ Match { m_ctxt = ctxt, m_pats = [p1, p2] + , m_type = Nothing, m_grhss = rhs } + where + ctxt = FunRhs { mc_fun = ln, mc_fixity = Infix, mc_strictness = NoSrcStrict } + RecCon{} -> recordPatSynErr loc pat ; return $ L loc match } fromDecl (L loc decl) = extraDeclErr loc decl @@ -960,7 +966,9 @@ checkFunBind msg strictness ann lhs_loc fun is_infix pats opt_sig (L rhs_span gr -- Add back the annotations stripped from any HsPar values in the lhs -- mapM_ (\a -> a match_span) ann return (ann, makeFunBind fun - [L match_span (Match { m_ctxt = FunRhs fun is_infix strictness + [L match_span (Match { m_ctxt = FunRhs { mc_fun = fun + , mc_fixity = is_infix + , mc_strictness = strictness } , m_pats = ps , m_type = opt_sig , m_grhss = grhss })]) @@ -1075,7 +1083,7 @@ isFunLhs e = go e [] [] go (L l (HsPar e)) es@(_:_) ann = go e es (ann ++ mkParensApiAnn l) -- Things of the form `!x` are also FunBinds - -- See Note [Varieties of binding pattern matches] + -- See Note [FunBind vs PatBind] go (L _ (SectionR (L _ (HsVar (L _ bang))) (L l (HsVar (L _ var))))) [] ann | bang == bang_RDR , not (isRdrDataCon var) = return (Just (L l var, Prefix, [], ann)) |