diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2013-01-04 10:30:14 +0000 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2013-01-04 10:30:14 +0000 |
commit | a8941e2a4fe3b000e6c085701e0c015c5316c6ee (patch) | |
tree | 7fefa2663395977c0ede0c348fef16d8f81d5a47 /compiler/parser | |
parent | 3671e674757c8f82ec1f0ea9b7c1ed56340b55bc (diff) | |
download | haskell-a8941e2a4fe3b000e6c085701e0c015c5316c6ee.tar.gz |
Refactor HsExpr.MatchGroup
* Make MatchGroup into a record, and use the record fields
* Split the type field into two: mg_arg_tys and mg_res_ty
This makes life much easier for the desugarer when the
case alterantives are empty
A little bit of this change unavoidably ended up in the preceding
commit about empty case alternatives
Diffstat (limited to 'compiler/parser')
-rw-r--r-- | compiler/parser/RdrHsSyn.lhs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/compiler/parser/RdrHsSyn.lhs b/compiler/parser/RdrHsSyn.lhs index f1fa5a44b6..6bd8701d7f 100644 --- a/compiler/parser/RdrHsSyn.lhs +++ b/compiler/parser/RdrHsSyn.lhs @@ -310,13 +310,13 @@ getMonoBind :: LHsBind RdrName -> [LHsDecl RdrName] -- No AndMonoBinds or EmptyMonoBinds here; just single equations getMonoBind (L loc1 (FunBind { fun_id = fun_id1@(L _ f1), fun_infix = is_infix1, - fun_matches = MatchGroup mtchs1 _ })) binds + fun_matches = MG { mg_alts = mtchs1 } })) binds | has_args mtchs1 = go is_infix1 mtchs1 loc1 binds [] where go is_infix mtchs loc (L loc2 (ValD (FunBind { fun_id = L _ f2, fun_infix = is_infix2, - fun_matches = MatchGroup mtchs2 _ })) : binds) _ + fun_matches = MG { mg_alts = mtchs2 } })) : binds) _ | f1 == f2 = go (is_infix || is_infix2) (mtchs2 ++ mtchs) (combineSrcSpans loc loc2) binds [] go is_infix mtchs loc (doc_decl@(L loc2 (DocD _)) : binds) doc_decls @@ -886,9 +886,9 @@ checkCmdStmt _ stmt@(RecStmt { recS_stmts = stmts }) = do checkCmdStmt l stmt = cmdStmtFail l stmt checkCmdMatchGroup :: MatchGroup RdrName (LHsExpr RdrName) -> P (MatchGroup RdrName (LHsCmd RdrName)) -checkCmdMatchGroup (MatchGroup ms ty) = do +checkCmdMatchGroup mg@(MG { mg_alts = ms }) = do ms' <- mapM (locMap $ const convert) ms - return $ MatchGroup ms' ty + return $ mg { mg_alts = ms' } where convert (Match pat mty grhss) = do grhss' <- checkCmdGRHSs grhss return $ Match pat mty grhss' |