diff options
author | romes <rodrigo.m.mesquita@gmail.com> | 2022-05-22 21:05:32 +0200 |
---|---|---|
committer | romes <rodrigo.m.mesquita@gmail.com> | 2022-05-26 16:27:57 +0000 |
commit | 44bb71115bcf1edaee82fc75cbe07a3e242e9476 (patch) | |
tree | c850a97d6279f5a94b9ffab97bca24df9df5e142 /compiler/GHC/Tc | |
parent | d0e4355af8c936a3ba831ecf6afa62b06475069f (diff) | |
download | haskell-44bb71115bcf1edaee82fc75cbe07a3e242e9476.tar.gz |
TTG: Move MatchGroup Origin field and MatchGroupTc to GHC.Hswip/romes/ttg-matchgroup-origin
Diffstat (limited to 'compiler/GHC/Tc')
-rw-r--r-- | compiler/GHC/Tc/Gen/Arrow.hs | 4 | ||||
-rw-r--r-- | compiler/GHC/Tc/Gen/Match.hs | 10 | ||||
-rw-r--r-- | compiler/GHC/Tc/TyCl/PatSyn.hs | 9 | ||||
-rw-r--r-- | compiler/GHC/Tc/Utils/Zonk.hs | 8 |
4 files changed, 14 insertions, 17 deletions
diff --git a/compiler/GHC/Tc/Gen/Arrow.hs b/compiler/GHC/Tc/Gen/Arrow.hs index a4eff74ea4..6e4166d36d 100644 --- a/compiler/GHC/Tc/Gen/Arrow.hs +++ b/compiler/GHC/Tc/Gen/Arrow.hs @@ -339,7 +339,7 @@ tcCmdMatchLambda :: CmdEnv -> TcM (HsWrapper, MatchGroup GhcTc (LHsCmd GhcTc)) tcCmdMatchLambda env ctxt - mg@MG { mg_alts = L l matches } + mg@MG { mg_alts = L l matches, mg_ext = origin } (cmd_stk, res_ty) = do { (co, arg_tys, cmd_stk') <- matchExpectedCmdArgs n_pats cmd_stk @@ -349,7 +349,7 @@ tcCmdMatchLambda env ; let arg_tys' = map unrestricted arg_tys mg' = mg { mg_alts = L l matches' - , mg_ext = MatchGroupTc arg_tys' res_ty } + , mg_ext = MatchGroupTc arg_tys' res_ty origin } ; return (mkWpCastN co, mg') } where diff --git a/compiler/GHC/Tc/Gen/Match.hs b/compiler/GHC/Tc/Gen/Match.hs index 9c838785ac..9646cfeace 100644 --- a/compiler/GHC/Tc/Gen/Match.hs +++ b/compiler/GHC/Tc/Gen/Match.hs @@ -223,7 +223,7 @@ tcMatches :: (AnnoBody body ) => TcMatchCtxt body -> TcM (MatchGroup GhcTc (LocatedA (body GhcTc))) tcMatches ctxt pat_tys rhs_ty (MG { mg_alts = L l matches - , mg_origin = origin }) + , mg_ext = origin }) | null matches -- Deal with case e of {} -- Since there are no branches, no one else will fill in rhs_ty -- when in inference mode, so we must do it ourselves, @@ -232,8 +232,8 @@ tcMatches ctxt pat_tys rhs_ty (MG { mg_alts = L l matches ; pat_tys <- mapM scaledExpTypeToType pat_tys ; rhs_ty <- expTypeToType rhs_ty ; return (MG { mg_alts = L l [] - , mg_ext = MatchGroupTc pat_tys rhs_ty - , mg_origin = origin }) } + , mg_ext = MatchGroupTc pat_tys rhs_ty origin + }) } | otherwise = do { umatches <- mapM (tcCollectingUsage . tcMatch ctxt pat_tys rhs_ty) matches @@ -242,8 +242,8 @@ tcMatches ctxt pat_tys rhs_ty (MG { mg_alts = L l matches ; pat_tys <- mapM readScaledExpType pat_tys ; rhs_ty <- readExpType rhs_ty ; return (MG { mg_alts = L l matches' - , mg_ext = MatchGroupTc pat_tys rhs_ty - , mg_origin = origin }) } + , mg_ext = MatchGroupTc pat_tys rhs_ty origin + }) } ------------- tcMatch :: (AnnoBody body) => TcMatchCtxt body diff --git a/compiler/GHC/Tc/TyCl/PatSyn.hs b/compiler/GHC/Tc/TyCl/PatSyn.hs index a306a3967e..7a3ca9e42a 100644 --- a/compiler/GHC/Tc/TyCl/PatSyn.hs +++ b/compiler/GHC/Tc/TyCl/PatSyn.hs @@ -830,15 +830,13 @@ tcPatSynMatcher (L loc ps_name) lpat prag_fn L (getLoc lpat) $ HsCase noExtField (nlHsVar scrutinee) $ MG{ mg_alts = L (l2l $ getLoc lpat) cases - , mg_ext = MatchGroupTc [unrestricted pat_ty] res_ty - , mg_origin = Generated + , mg_ext = MatchGroupTc [unrestricted pat_ty] res_ty Generated } body' = noLocA $ HsLam noExtField $ MG{ mg_alts = noLocA [mkSimpleMatch LambdaExpr args body] - , mg_ext = MatchGroupTc (map unrestricted [pat_ty, cont_ty, fail_ty]) res_ty - , mg_origin = Generated + , mg_ext = MatchGroupTc (map unrestricted [pat_ty, cont_ty, fail_ty]) res_ty Generated } match = mkMatch (mkPrefixFunRhs (L loc patsyn_id)) [] (mkHsLams (rr_tv:res_tv:univ_tvs) @@ -846,8 +844,7 @@ tcPatSynMatcher (L loc ps_name) lpat prag_fn (EmptyLocalBinds noExtField) mg :: MatchGroup GhcTc (LHsExpr GhcTc) mg = MG{ mg_alts = L (l2l $ getLoc match) [match] - , mg_ext = MatchGroupTc [] res_ty - , mg_origin = Generated + , mg_ext = MatchGroupTc [] res_ty Generated } matcher_arity = length req_theta + 3 -- See Note [Pragmas for pattern synonyms] diff --git a/compiler/GHC/Tc/Utils/Zonk.hs b/compiler/GHC/Tc/Utils/Zonk.hs index 6fa47f8b64..b5fbea49ed 100644 --- a/compiler/GHC/Tc/Utils/Zonk.hs +++ b/compiler/GHC/Tc/Utils/Zonk.hs @@ -674,14 +674,14 @@ zonkMatchGroup :: Anno (GRHS GhcTc (LocatedA (body GhcTc))) ~ SrcAnn NoEpAnns -> MatchGroup GhcTc (LocatedA (body GhcTc)) -> TcM (MatchGroup GhcTc (LocatedA (body GhcTc))) zonkMatchGroup env zBody (MG { mg_alts = L l ms - , mg_ext = MatchGroupTc arg_tys res_ty - , mg_origin = origin }) + , mg_ext = MatchGroupTc arg_tys res_ty origin + }) = do { ms' <- mapM (zonkMatch env zBody) ms ; arg_tys' <- zonkScaledTcTypesToTypesX env arg_tys ; res_ty' <- zonkTcTypeToTypeX env res_ty ; return (MG { mg_alts = L l ms' - , mg_ext = MatchGroupTc arg_tys' res_ty' - , mg_origin = origin }) } + , mg_ext = MatchGroupTc arg_tys' res_ty' origin + }) } zonkMatch :: Anno (GRHS GhcTc (LocatedA (body GhcTc))) ~ SrcAnn NoEpAnns => ZonkEnv |