diff options
author | Alan Zimmerman <alan.zimm@gmail.com> | 2020-09-27 22:26:08 +0100 |
---|---|---|
committer | Alan Zimmerman <alan.zimm@gmail.com> | 2020-09-27 22:26:08 +0100 |
commit | 53be968726a249d66fbc2ebd3dd0ff090a04b619 (patch) | |
tree | 71bd8d98483e0c0891eb9ae264d2bda836add44f | |
parent | a9ce159ba58ca7e8946b46e19b1361588b677a26 (diff) | |
download | haskell-wip/az/hsmatchcontext.tar.gz |
Use id rather than pass for HsStmtContext and HsMatchContextwip/az/hsmatchcontext
The fundamental change is for FunRhs, where mc_fun goes from `LIdP p`
to `Located id`.
The rest are related administrative changes.
This is a precursor for the in-tree API annotations, !2418, #17638,
where it is required.
It makes the endless rebases simpler until it lands.
-rw-r--r-- | compiler/GHC/Hs/Expr.hs | 52 | ||||
-rw-r--r-- | compiler/GHC/Hs/Instances.hs | 8 | ||||
-rw-r--r-- | compiler/GHC/Hs/Utils.hs | 12 | ||||
-rw-r--r-- | compiler/GHC/HsToCore/Arrows.hs | 5 | ||||
-rw-r--r-- | compiler/GHC/HsToCore/Expr.hs | 2 | ||||
-rw-r--r-- | compiler/GHC/HsToCore/GuardedRHSs.hs | 7 | ||||
-rw-r--r-- | compiler/GHC/HsToCore/ListComp.hs | 3 | ||||
-rw-r--r-- | compiler/GHC/HsToCore/Match.hs | 10 | ||||
-rw-r--r-- | compiler/GHC/HsToCore/Match.hs-boot | 9 | ||||
-rw-r--r-- | compiler/GHC/HsToCore/Monad.hs | 2 | ||||
-rw-r--r-- | compiler/GHC/HsToCore/Pmc.hs | 3 | ||||
-rw-r--r-- | compiler/GHC/HsToCore/Utils.hs | 6 | ||||
-rw-r--r-- | compiler/GHC/Iface/Ext/Ast.hs | 4 | ||||
-rw-r--r-- | compiler/GHC/Parser/PostProcess.hs | 6 | ||||
-rw-r--r-- | compiler/GHC/Rename/Bind.hs | 14 | ||||
-rw-r--r-- | compiler/GHC/Rename/Expr.hs | 52 | ||||
-rw-r--r-- | compiler/GHC/Rename/Expr.hs-boot | 2 | ||||
-rw-r--r-- | compiler/GHC/Rename/Pat.hs | 4 | ||||
-rw-r--r-- | compiler/GHC/Tc/Deriv/Functor.hs | 6 | ||||
-rw-r--r-- | compiler/GHC/Tc/Gen/Arrow.hs | 3 | ||||
-rw-r--r-- | compiler/GHC/Tc/Gen/Match.hs | 12 | ||||
-rw-r--r-- | compiler/GHC/Tc/Gen/Pat.hs | 10 | ||||
-rw-r--r-- | compiler/GHC/Tc/Types/Origin.hs | 2 | ||||
-rw-r--r-- | compiler/GHC/ThToHs.hs | 6 |
24 files changed, 121 insertions, 119 deletions
diff --git a/compiler/GHC/Hs/Expr.hs b/compiler/GHC/Hs/Expr.hs index 11a102f91b..c1d223a207 100644 --- a/compiler/GHC/Hs/Expr.hs +++ b/compiler/GHC/Hs/Expr.hs @@ -42,6 +42,7 @@ import GHC.Tc.Types.Evidence import GHC.Core import GHC.Types.Id( Id ) import GHC.Types.Name +import GHC.Types.Name.Reader (RdrName) import GHC.Types.Name.Set import GHC.Types.Basic import GHC.Core.ConLike @@ -415,7 +416,7 @@ data HsExpr p -- For details on above see note [Api annotations] in GHC.Parser.Annotation | HsDo (XDo p) -- Type of the whole expression - (HsStmtContext GhcRn) -- The parameterisation is unimportant + (HsStmtContext Name) -- The parameterisation is unimportant -- because in this context we never use -- the PatGuard or ParStmt variant (XRec p [ExprLStmt p]) -- "do":one or more stmts @@ -1731,7 +1732,7 @@ type LMatch id body = XRec id (Match id body) data Match p body = Match { m_ext :: XCMatch p body, - m_ctxt :: HsMatchContext (NoGhcTc p), + m_ctxt :: HsMatchContext (IdP (NoGhcTc p)), -- See note [m_ctxt in Match] m_pats :: [LPat p], -- The patterns m_grhss :: (GRHSs p body) @@ -2205,7 +2206,7 @@ data ApplicativeArg idL , app_stmts :: [ExprLStmt idL] -- stmts , final_expr :: HsExpr idL -- return (v1,..,vn), or just (v1,..,vn) , bv_pattern :: LPat idL -- (v1,...,vn) - , stmt_context :: HsStmtContext GhcRn -- context of the do expression + , stmt_context :: HsStmtContext Name -- context of the do expression -- used in pprArg } | XApplicativeArg !(XXApplicativeArg idL) @@ -2875,8 +2876,8 @@ pp_dotdot = text " .. " -- -- Context of a pattern match. This is more subtle than it would seem. See Note -- [Varieties of pattern matches]. -data HsMatchContext p - = FunRhs { mc_fun :: LIdP p -- ^ function binder of @f@ +data HsMatchContext id -- Not an extensible tag + = FunRhs { mc_fun :: Located id -- ^ function binder of @f@ , mc_fixity :: LexicalFixity -- ^ fixing of @f@ , mc_strictness :: SrcStrictness -- ^ was @f@ banged? -- See Note [FunBind vs PatBind] @@ -2896,14 +2897,16 @@ data HsMatchContext p -- tell matchWrapper what sort of -- runtime error message to generate] - | StmtCtxt (HsStmtContext p) -- ^Pattern of a do-stmt, list comprehension, - -- pattern guard, etc + | StmtCtxt (HsStmtContext id) -- ^Pattern of a do-stmt, list comprehension, + -- pattern guard, etc | ThPatSplice -- ^A Template Haskell pattern splice | ThPatQuote -- ^A Template Haskell pattern quotation [p| (a,b) |] | PatSyn -- ^A pattern synonym declaration +deriving instance Data (HsMatchContext RdrName) +deriving instance Data (HsMatchContext Name) -instance OutputableBndrId p => Outputable (HsMatchContext (GhcPass p)) where +instance Outputable p => Outputable (HsMatchContext p) where ppr m@(FunRhs{}) = text "FunRhs" <+> ppr (mc_fun m) <+> ppr (mc_fixity m) ppr LambdaExpr = text "LambdaExpr" ppr CaseAlt = text "CaseAlt" @@ -2924,7 +2927,7 @@ isPatSynCtxt ctxt = _ -> False -- | Haskell Statement Context. -data HsStmtContext p +data HsStmtContext id -- Not a pass = ListComp | MonadComp @@ -2933,9 +2936,11 @@ data HsStmtContext p | ArrowExpr -- ^do-notation in an arrow-command context | GhciStmtCtxt -- ^A command-line Stmt in GHCi pat <- rhs - | PatGuard (HsMatchContext p) -- ^Pattern guard for specified thing - | ParStmtCtxt (HsStmtContext p) -- ^A branch of a parallel stmt - | TransStmtCtxt (HsStmtContext p) -- ^A branch of a transform stmt + | PatGuard (HsMatchContext id) -- ^Pattern guard for specified thing + | ParStmtCtxt (HsStmtContext id) -- ^A branch of a parallel stmt + | TransStmtCtxt (HsStmtContext id) -- ^A branch of a transform stmt +deriving instance Data (HsStmtContext RdrName) +deriving instance Data (HsStmtContext Name) qualifiedDoModuleName_maybe :: HsStmtContext p -> Maybe ModuleName qualifiedDoModuleName_maybe ctxt = case ctxt of @@ -2980,7 +2985,7 @@ matchSeparator ThPatSplice = panic "unused" matchSeparator ThPatQuote = panic "unused" matchSeparator PatSyn = panic "unused" -pprMatchContext :: (Outputable (IdP p), UnXRec p) +pprMatchContext :: Outputable p => HsMatchContext p -> SDoc pprMatchContext ctxt | want_an ctxt = text "an" <+> pprMatchContextNoun ctxt @@ -2990,11 +2995,11 @@ pprMatchContext ctxt want_an ProcExpr = True want_an _ = False -pprMatchContextNoun :: forall p. (Outputable (IdP p), UnXRec p) - => HsMatchContext p -> SDoc -pprMatchContextNoun (FunRhs {mc_fun=fun}) +pprMatchContextNoun :: Outputable id + => HsMatchContext id -> SDoc +pprMatchContextNoun (FunRhs {mc_fun=L _ fun}) = text "equation for" - <+> quotes (ppr (unXRec @p fun)) + <+> quotes (ppr fun) pprMatchContextNoun CaseAlt = text "case alternative" pprMatchContextNoun IfAlt = text "multi-way if alternative" pprMatchContextNoun RecUpd = text "record-update construct" @@ -3009,8 +3014,8 @@ pprMatchContextNoun (StmtCtxt ctxt) = text "pattern binding in" pprMatchContextNoun PatSyn = text "pattern synonym declaration" ----------------- -pprAStmtContext, pprStmtContext :: (Outputable (IdP p), UnXRec p) - => HsStmtContext p -> SDoc +pprAStmtContext, pprStmtContext :: Outputable id + => HsStmtContext id -> SDoc pprAStmtContext ctxt = article <+> pprStmtContext ctxt where pp_an = text "an" @@ -3046,13 +3051,12 @@ prependQualified :: Maybe ModuleName -> SDoc -> SDoc prependQualified Nothing t = t prependQualified (Just _) t = text "qualified" <+> t -instance OutputableBndrId p - => Outputable (HsStmtContext (GhcPass p)) where +instance Outputable id => Outputable (HsStmtContext id) where ppr = pprStmtContext -- Used to generate the string for a *runtime* error message -matchContextErrString :: OutputableBndrId p - => HsMatchContext (GhcPass p) -> SDoc +matchContextErrString :: Outputable id + => HsMatchContext id -> SDoc matchContextErrString (FunRhs{mc_fun=L _ fun}) = text "function" <+> ppr fun matchContextErrString CaseAlt = text "case" matchContextErrString IfAlt = text "multi-way if" @@ -3083,7 +3087,7 @@ pprMatchInCtxt match = hang (text "In" <+> pprMatchContext (m_ctxt match) pprStmtInCtxt :: (OutputableBndrId idL, OutputableBndrId idR, Outputable body) - => HsStmtContext (GhcPass idL) + => HsStmtContext (IdP (GhcPass idL)) -> StmtLR (GhcPass idL) (GhcPass idR) body -> SDoc pprStmtInCtxt ctxt (LastStmt _ e _ _) diff --git a/compiler/GHC/Hs/Instances.hs b/compiler/GHC/Hs/Instances.hs index e1f3d29f21..95c5e7342f 100644 --- a/compiler/GHC/Hs/Instances.hs +++ b/compiler/GHC/Hs/Instances.hs @@ -320,14 +320,6 @@ deriving instance Data (ApplicativeArg GhcPs) deriving instance Data (ApplicativeArg GhcRn) deriving instance Data (ApplicativeArg GhcTc) -deriving instance Data (HsStmtContext GhcPs) -deriving instance Data (HsStmtContext GhcRn) -deriving instance Data (HsStmtContext GhcTc) - -deriving instance Data (HsMatchContext GhcPs) -deriving instance Data (HsMatchContext GhcRn) -deriving instance Data (HsMatchContext GhcTc) - -- deriving instance (DataIdLR p p) => Data (HsSplice p) deriving instance Data (HsSplice GhcPs) deriving instance Data (HsSplice GhcRn) diff --git a/compiler/GHC/Hs/Utils.hs b/compiler/GHC/Hs/Utils.hs index 5adcc140e2..fa1f910095 100644 --- a/compiler/GHC/Hs/Utils.hs +++ b/compiler/GHC/Hs/Utils.hs @@ -159,7 +159,7 @@ just attach 'noSrcSpan' to everything. mkHsPar :: LHsExpr (GhcPass id) -> LHsExpr (GhcPass id) mkHsPar e = L (getLoc e) (HsPar noExtField e) -mkSimpleMatch :: HsMatchContext (NoGhcTc (GhcPass p)) +mkSimpleMatch :: HsMatchContext (IdP (NoGhcTc (GhcPass p))) -> [LPat (GhcPass p)] -> Located (body (GhcPass p)) -> LMatch (GhcPass p) (Located (body (GhcPass p))) mkSimpleMatch ctxt pats rhs @@ -273,8 +273,8 @@ nlParPat p = noLoc (ParPat noExtField p) mkHsIntegral :: IntegralLit -> HsOverLit GhcPs mkHsFractional :: FractionalLit -> HsOverLit GhcPs mkHsIsString :: SourceText -> FastString -> HsOverLit GhcPs -mkHsDo :: HsStmtContext GhcRn -> [ExprLStmt GhcPs] -> HsExpr GhcPs -mkHsComp :: HsStmtContext GhcRn -> [ExprLStmt GhcPs] -> LHsExpr GhcPs +mkHsDo :: HsStmtContext Name -> [ExprLStmt GhcPs] -> HsExpr GhcPs +mkHsComp :: HsStmtContext Name -> [ExprLStmt GhcPs] -> LHsExpr GhcPs -> HsExpr GhcPs mkNPat :: Located (HsOverLit GhcPs) -> Maybe (SyntaxExpr GhcPs) @@ -510,7 +510,7 @@ nlWildPat = noLoc (WildPat noExtField ) nlWildPatName :: LPat GhcRn nlWildPatName = noLoc (WildPat noExtField ) -nlHsDo :: HsStmtContext GhcRn -> [LStmt GhcPs (LHsExpr GhcPs)] +nlHsDo :: HsStmtContext Name -> [LStmt GhcPs (LHsExpr GhcPs)] -> LHsExpr GhcPs nlHsDo ctxt stmts = noLoc (mkHsDo ctxt stmts) @@ -806,14 +806,14 @@ mkSimpleGeneratedFunBind loc fun pats expr (noLoc emptyLocalBinds)] -- | Make a prefix, non-strict function 'HsMatchContext' -mkPrefixFunRhs :: LIdP p -> HsMatchContext p +mkPrefixFunRhs :: Located id -> HsMatchContext id mkPrefixFunRhs n = FunRhs { mc_fun = n , mc_fixity = Prefix , mc_strictness = NoSrcStrict } ------------ mkMatch :: forall p. IsPass p - => HsMatchContext (NoGhcTc (GhcPass p)) + => HsMatchContext (IdP (NoGhcTc (GhcPass p))) -> [LPat (GhcPass p)] -> LHsExpr (GhcPass p) -> Located (HsLocalBinds (GhcPass p)) diff --git a/compiler/GHC/HsToCore/Arrows.hs b/compiler/GHC/HsToCore/Arrows.hs index 6668e9a11b..68818bbe54 100644 --- a/compiler/GHC/HsToCore/Arrows.hs +++ b/compiler/GHC/HsToCore/Arrows.hs @@ -47,6 +47,7 @@ import GHC.Core.Make import GHC.HsToCore.Binds (dsHsWrapper) import GHC.Types.Id +import GHC.Types.Name import GHC.Core.ConLike import GHC.Builtin.Types import GHC.Types.Basic @@ -170,7 +171,7 @@ do_premap :: DsCmdEnv -> Type -> Type -> Type -> do_premap ids b_ty c_ty d_ty f g = do_compose ids b_ty c_ty d_ty (do_arr ids b_ty c_ty f) g -mkFailExpr :: HsMatchContext GhcRn -> Type -> DsM CoreExpr +mkFailExpr :: HsMatchContext Name -> Type -> DsM CoreExpr mkFailExpr ctxt ty = mkErrorAppDs pAT_ERROR_ID ty (matchContextErrString ctxt) @@ -1144,7 +1145,7 @@ dsCmdStmts _ _ _ [] _ = panic "dsCmdStmts []" -- Match a list of expressions against a list of patterns, left-to-right. matchSimplys :: [CoreExpr] -- Scrutinees - -> HsMatchContext GhcRn -- Match kind + -> HsMatchContext Name -- Match kind -> [LPat GhcTc] -- Patterns they should match -> CoreExpr -- Return this if they all match -> CoreExpr -- Return this if they don't diff --git a/compiler/GHC/HsToCore/Expr.hs b/compiler/GHC/HsToCore/Expr.hs index 5f1aa24035..fa514ae9fe 100644 --- a/compiler/GHC/HsToCore/Expr.hs +++ b/compiler/GHC/HsToCore/Expr.hs @@ -959,7 +959,7 @@ handled in GHC.HsToCore.ListComp). Basically does the translation given in the Haskell 98 report: -} -dsDo :: HsStmtContext GhcRn -> [ExprLStmt GhcTc] -> DsM CoreExpr +dsDo :: HsStmtContext Name -> [ExprLStmt GhcTc] -> DsM CoreExpr dsDo ctx stmts = goL stmts where diff --git a/compiler/GHC/HsToCore/GuardedRHSs.hs b/compiler/GHC/HsToCore/GuardedRHSs.hs index c2ac2f0ef8..84cccd46e6 100644 --- a/compiler/GHC/HsToCore/GuardedRHSs.hs +++ b/compiler/GHC/HsToCore/GuardedRHSs.hs @@ -34,6 +34,7 @@ import GHC.Utils.Panic import GHC.Core.Multiplicity import Control.Monad ( zipWithM ) import Data.List.NonEmpty ( NonEmpty, toList ) +import GHC.Types.Name {- @dsGuarded@ is used for GRHSs. @@ -56,7 +57,7 @@ dsGuarded grhss rhs_ty rhss_nablas = do -- In contrast, @dsGRHSs@ produces a @MatchResult CoreExpr@. -dsGRHSs :: HsMatchContext GhcRn +dsGRHSs :: HsMatchContext Name -> GRHSs GhcTc (LHsExpr GhcTc) -- ^ Guarded RHSs -> Type -- ^ Type of RHS -> NonEmpty Nablas -- ^ Refined pattern match checking @@ -77,7 +78,7 @@ dsGRHSs hs_ctx (GRHSs _ grhss binds) rhs_ty rhss_nablas -- NB: nested dsLet inside matchResult ; return match_result2 } -dsGRHS :: HsMatchContext GhcRn -> Type -> Nablas -> LGRHS GhcTc (LHsExpr GhcTc) +dsGRHS :: HsMatchContext Name -> Type -> Nablas -> LGRHS GhcTc (LHsExpr GhcTc) -> DsM (MatchResult CoreExpr) dsGRHS hs_ctx rhs_ty rhs_nablas (L _ (GRHS _ guards rhs)) = matchGuards (map unLoc guards) (PatGuard hs_ctx) rhs_nablas rhs rhs_ty @@ -91,7 +92,7 @@ dsGRHS hs_ctx rhs_ty rhs_nablas (L _ (GRHS _ guards rhs)) -} matchGuards :: [GuardStmt GhcTc] -- Guard - -> HsStmtContext GhcRn -- Context + -> HsStmtContext Name -- Context -> Nablas -- The RHS's covered set for PmCheck -> LHsExpr GhcTc -- RHS -> Type -- Type of RHS of guard diff --git a/compiler/GHC/HsToCore/ListComp.hs b/compiler/GHC/HsToCore/ListComp.hs index 19d46c1f2f..5b89463778 100644 --- a/compiler/GHC/HsToCore/ListComp.hs +++ b/compiler/GHC/HsToCore/ListComp.hs @@ -29,6 +29,7 @@ import GHC.HsToCore.Utils import GHC.Driver.Session import GHC.Core.Utils import GHC.Types.Id +import GHC.Types.Name import GHC.Core.Type import GHC.Builtin.Types import GHC.HsToCore.Match @@ -619,7 +620,7 @@ dsMcBindStmt pat rhs' bind_op fail_op res1_ty stmts ; var <- selectSimpleMatchVarL Many pat ; match <- matchSinglePatVar var Nothing (StmtCtxt (DoExpr Nothing)) pat res1_ty (cantFailMatchResult body) - ; match_code <- dsHandleMonadicFailure (MonadComp :: HsStmtContext GhcRn) pat match fail_op + ; match_code <- dsHandleMonadicFailure (MonadComp :: HsStmtContext Name) pat match fail_op ; dsSyntaxExpr bind_op [rhs', Lam var match_code] } -- Desugar nested monad comprehensions, for example in `then..` constructs diff --git a/compiler/GHC/HsToCore/Match.hs b/compiler/GHC/HsToCore/Match.hs index afc31ec58d..43a1710e0c 100644 --- a/compiler/GHC/HsToCore/Match.hs +++ b/compiler/GHC/HsToCore/Match.hs @@ -716,7 +716,7 @@ Call @match@ with all of this information! -} matchWrapper - :: HsMatchContext GhcRn -- ^ For shadowing warning messages + :: HsMatchContext Name -- ^ For shadowing warning messages -> Maybe (LHsExpr GhcTc) -- ^ Scrutinee. (Just scrut) for a case expr -- case scrut of { p1 -> e1 ... } -- (and in this case the MatchGroup will @@ -809,7 +809,7 @@ matchWrapper ctxt mb_scr (MG { mg_alts = L _ matches $ replicate (length (grhssGRHSs m)) initNablas -matchEquations :: HsMatchContext GhcRn +matchEquations :: HsMatchContext Name -> [MatchId] -> [EquationInfo] -> Type -> DsM CoreExpr matchEquations ctxt vars eqns_info rhs_ty @@ -824,7 +824,7 @@ matchEquations ctxt vars eqns_info rhs_ty -- situation where we want to match a single expression against a single -- pattern. It returns an expression. matchSimply :: CoreExpr -- ^ Scrutinee - -> HsMatchContext GhcRn -- ^ Match kind + -> HsMatchContext Name -- ^ Match kind -> LPat GhcTc -- ^ Pattern it should match -> CoreExpr -- ^ Return this if it matches -> CoreExpr -- ^ Return this if it doesn't @@ -846,7 +846,7 @@ matchSimply scrut hs_ctx pat result_expr fail_expr = do match_result' <- matchSinglePat scrut hs_ctx pat rhs_ty match_result extractMatchResult match_result' fail_expr -matchSinglePat :: CoreExpr -> HsMatchContext GhcRn -> LPat GhcTc +matchSinglePat :: CoreExpr -> HsMatchContext Name -> LPat GhcTc -> Type -> MatchResult CoreExpr -> DsM (MatchResult CoreExpr) -- matchSinglePat ensures that the scrutinee is a variable -- and then calls matchSinglePatVar @@ -872,7 +872,7 @@ matchSinglePat scrut hs_ctx pat ty match_result matchSinglePatVar :: Id -- See Note [Match Ids] -> Maybe CoreExpr -- ^ The scrutinee the match id is bound to - -> HsMatchContext GhcRn -> LPat GhcTc + -> HsMatchContext Name -> LPat GhcTc -> Type -> MatchResult CoreExpr -> DsM (MatchResult CoreExpr) matchSinglePatVar var mb_scrut ctx pat ty match_result = ASSERT2( isInternalName (idName var), ppr var ) diff --git a/compiler/GHC/HsToCore/Match.hs-boot b/compiler/GHC/HsToCore/Match.hs-boot index 3014c069a5..51b17e3900 100644 --- a/compiler/GHC/HsToCore/Match.hs-boot +++ b/compiler/GHC/HsToCore/Match.hs-boot @@ -6,7 +6,8 @@ import GHC.Tc.Utils.TcType ( Type ) import GHC.HsToCore.Monad ( DsM, EquationInfo, MatchResult ) import GHC.Core ( CoreExpr ) import GHC.Hs ( LPat, HsMatchContext, MatchGroup, LHsExpr ) -import GHC.Hs.Extension ( GhcRn, GhcTc ) +import GHC.Hs.Extension ( GhcTc ) +import GHC.Types.Name ( Name ) match :: [Id] -> Type @@ -14,14 +15,14 @@ match :: [Id] -> DsM (MatchResult CoreExpr) matchWrapper - :: HsMatchContext GhcRn + :: HsMatchContext Name -> Maybe (LHsExpr GhcTc) -> MatchGroup GhcTc (LHsExpr GhcTc) -> DsM ([Id], CoreExpr) matchSimply :: CoreExpr - -> HsMatchContext GhcRn + -> HsMatchContext Name -> LPat GhcTc -> CoreExpr -> CoreExpr @@ -30,7 +31,7 @@ matchSimply matchSinglePatVar :: Id -> Maybe CoreExpr - -> HsMatchContext GhcRn + -> HsMatchContext Name -> LPat GhcTc -> Type -> MatchResult CoreExpr diff --git a/compiler/GHC/HsToCore/Monad.hs b/compiler/GHC/HsToCore/Monad.hs index fce4e2d580..d550977f55 100644 --- a/compiler/GHC/HsToCore/Monad.hs +++ b/compiler/GHC/HsToCore/Monad.hs @@ -104,7 +104,7 @@ import Data.IORef -} data DsMatchContext - = DsMatchContext (HsMatchContext GhcRn) SrcSpan + = DsMatchContext (HsMatchContext Name) SrcSpan deriving () instance Outputable DsMatchContext where diff --git a/compiler/GHC/HsToCore/Pmc.hs b/compiler/GHC/HsToCore/Pmc.hs index d621e65c4b..0402301b3a 100644 --- a/compiler/GHC/HsToCore/Pmc.hs +++ b/compiler/GHC/HsToCore/Pmc.hs @@ -65,6 +65,7 @@ import GHC.Types.SrcLoc import GHC.Utils.Misc import GHC.Utils.Outputable import GHC.Utils.Panic +import GHC.Types.Name (Name) import GHC.Types.Var (EvVar) import GHC.Tc.Utils.TcType (evVarPred) import {-# SOURCE #-} GHC.HsToCore.Expr (dsLExpr) @@ -110,7 +111,7 @@ pmcPatBind _ _ _ = pure () -- | Exhaustive for guard matches, is used for guards in pattern bindings and -- in @MultiIf@ expressions. Returns the 'Nablas' covered by the RHSs. pmcGRHSs - :: HsMatchContext GhcRn -- ^ Match context, for warning messages + :: HsMatchContext Name -- ^ Match context, for warning messages -> GRHSs GhcTc (LHsExpr GhcTc) -- ^ The GRHSs to check -> DsM (NonEmpty Nablas) -- ^ Covered 'Nablas' for each RHS, for long -- distance info diff --git a/compiler/GHC/HsToCore/Utils.hs b/compiler/GHC/HsToCore/Utils.hs index b4d1b1b761..0bf462b49d 100644 --- a/compiler/GHC/HsToCore/Utils.hs +++ b/compiler/GHC/HsToCore/Utils.hs @@ -75,7 +75,7 @@ import GHC.Types.Unique.Set import GHC.Types.Unique.Supply import GHC.Unit.Module import GHC.Builtin.Names -import GHC.Types.Name( isInternalName ) +import GHC.Types.Name(Name, isInternalName ) import GHC.Utils.Outputable import GHC.Utils.Panic import GHC.Types.SrcLoc @@ -900,7 +900,7 @@ CPR-friendly. This matters a lot: if you don't get it right, you lose the tail call property. For example, see #3403. -} -dsHandleMonadicFailure :: HsStmtContext GhcRn -> LPat GhcTc -> MatchResult CoreExpr -> FailOperator GhcTc -> DsM CoreExpr +dsHandleMonadicFailure :: HsStmtContext Name -> LPat GhcTc -> MatchResult CoreExpr -> FailOperator GhcTc -> DsM CoreExpr -- In a do expression, pattern-match failure just calls -- the monadic 'fail' rather than throwing an exception dsHandleMonadicFailure ctx pat match m_fail_op = @@ -921,7 +921,7 @@ dsHandleMonadicFailure ctx pat match m_fail_op = fail_expr <- dsSyntaxExpr fail_op [fail_msg] body fail_expr -mk_fail_msg :: DynFlags -> HsStmtContext GhcRn -> Located e -> String +mk_fail_msg :: DynFlags -> HsStmtContext Name -> Located e -> String mk_fail_msg dflags ctx pat = showPpr dflags $ text "Pattern match failure in" <+> pprStmtContext ctx <+> text "at" <+> ppr (getLoc pat) diff --git a/compiler/GHC/Iface/Ext/Ast.hs b/compiler/GHC/Iface/Ext/Ast.hs index 68bbc103b5..d356bc1c11 100644 --- a/compiler/GHC/Iface/Ext/Ast.hs +++ b/compiler/GHC/Iface/Ext/Ast.hs @@ -900,12 +900,12 @@ instance ( HiePass p HieTc -> makeNode m span HieRn -> makeNode m span -instance HiePass p => ToHie (HsMatchContext (GhcPass p)) where +instance ToHie (Context (Located n)) => ToHie (HsMatchContext n) where toHie (FunRhs{mc_fun=name}) = toHie $ C MatchBind name toHie (StmtCtxt a) = toHie a toHie _ = pure [] -instance HiePass p => ToHie (HsStmtContext (GhcPass p)) where +instance ToHie (Context (Located n)) => ToHie (HsStmtContext n) where toHie (PatGuard a) = toHie a toHie (ParStmtCtxt a) = toHie a toHie (TransStmtCtxt a) = toHie a diff --git a/compiler/GHC/Parser/PostProcess.hs b/compiler/GHC/Parser/PostProcess.hs index 9014c9f159..04785bfba7 100644 --- a/compiler/GHC/Parser/PostProcess.hs +++ b/compiler/GHC/Parser/PostProcess.hs @@ -59,7 +59,7 @@ module GHC.Parser.PostProcess ( checkContext, -- HsType -> P HsContext checkPattern, -- HsExp -> P HsPat checkPattern_msg, - checkMonadComp, -- P (HsStmtContext GhcPs) + checkMonadComp, -- P (HsStmtContext RdrName) checkValDef, -- (SrcLoc, HsExp, HsRhs, [HsDecl]) -> P HsDecl checkValSigLhs, LRuleTyTmVar, RuleTyTmVar(..), @@ -1324,7 +1324,7 @@ addUnpackednessP (L lprag (UnpackednessPragma anns prag unpk)) ty = do -- If the flag MonadComprehensions is set, return a 'MonadComp' context, -- otherwise use the usual 'ListComp' context -checkMonadComp :: PV (HsStmtContext GhcRn) +checkMonadComp :: PV (HsStmtContext Name) checkMonadComp = do monadComprehensions <- getBit MonadComprehensionsBit return $ if monadComprehensions @@ -2096,7 +2096,7 @@ data Frame -- ^ If-expression: if p then x else y | FrameCase LFrame [LFrameMatch] -- ^ Case-expression: case x of { p1 -> e1; p2 -> e2 } - | FrameDo (HsStmtContext GhcRn) [LFrameStmt] + | FrameDo (HsStmtContext Name) [LFrameStmt] -- ^ Do-expression: do { s1; a <- s2; s3 } ... | FrameExpr (HsExpr GhcPs) -- unambiguously an expression diff --git a/compiler/GHC/Rename/Bind.hs b/compiler/GHC/Rename/Bind.hs index 9215ef26fc..0c184f7697 100644 --- a/compiler/GHC/Rename/Bind.hs +++ b/compiler/GHC/Rename/Bind.hs @@ -1157,7 +1157,7 @@ checkDupMinimalSigs sigs ************************************************************************ -} -rnMatchGroup :: Outputable (body GhcPs) => HsMatchContext GhcRn +rnMatchGroup :: Outputable (body GhcPs) => HsMatchContext Name -> (Located (body GhcPs) -> RnM (Located (body GhcRn), FreeVars)) -> MatchGroup GhcPs (Located (body GhcPs)) -> RnM (MatchGroup GhcRn (Located (body GhcRn)), FreeVars) @@ -1167,13 +1167,13 @@ rnMatchGroup ctxt rnBody (MG { mg_alts = L _ ms, mg_origin = origin }) ; (new_ms, ms_fvs) <- mapFvRn (rnMatch ctxt rnBody) ms ; return (mkMatchGroup origin new_ms, ms_fvs) } -rnMatch :: Outputable (body GhcPs) => HsMatchContext GhcRn +rnMatch :: Outputable (body GhcPs) => HsMatchContext Name -> (Located (body GhcPs) -> RnM (Located (body GhcRn), FreeVars)) -> LMatch GhcPs (Located (body GhcPs)) -> RnM (LMatch GhcRn (Located (body GhcRn)), FreeVars) rnMatch ctxt rnBody = wrapLocFstM (rnMatch' ctxt rnBody) -rnMatch' :: Outputable (body GhcPs) => HsMatchContext GhcRn +rnMatch' :: Outputable (body GhcPs) => HsMatchContext Name -> (Located (body GhcPs) -> RnM (Located (body GhcRn), FreeVars)) -> Match GhcPs (Located (body GhcPs)) -> RnM (Match GhcRn (Located (body GhcRn)), FreeVars) @@ -1188,7 +1188,7 @@ rnMatch' ctxt rnBody (Match { m_ctxt = mf, m_pats = pats, m_grhss = grhss }) ; return (Match { m_ext = noExtField, m_ctxt = mf', m_pats = pats' , m_grhss = grhss'}, grhss_fvs ) }} -emptyCaseErr :: HsMatchContext GhcRn -> SDoc +emptyCaseErr :: HsMatchContext Name -> SDoc emptyCaseErr ctxt = hang (text "Empty list of alternatives in" <+> pp_ctxt) 2 (text "Use EmptyCase to allow this") where @@ -1205,7 +1205,7 @@ emptyCaseErr ctxt = hang (text "Empty list of alternatives in" <+> pp_ctxt) ************************************************************************ -} -rnGRHSs :: HsMatchContext GhcRn +rnGRHSs :: HsMatchContext Name -> (Located (body GhcPs) -> RnM (Located (body GhcRn), FreeVars)) -> GRHSs GhcPs (Located (body GhcPs)) -> RnM (GRHSs GhcRn (Located (body GhcRn)), FreeVars) @@ -1214,13 +1214,13 @@ rnGRHSs ctxt rnBody (GRHSs _ grhss (L l binds)) (grhss', fvGRHSs) <- mapFvRn (rnGRHS ctxt rnBody) grhss return (GRHSs noExtField grhss' (L l binds'), fvGRHSs) -rnGRHS :: HsMatchContext GhcRn +rnGRHS :: HsMatchContext Name -> (Located (body GhcPs) -> RnM (Located (body GhcRn), FreeVars)) -> LGRHS GhcPs (Located (body GhcPs)) -> RnM (LGRHS GhcRn (Located (body GhcRn)), FreeVars) rnGRHS ctxt rnBody = wrapLocFstM (rnGRHS' ctxt rnBody) -rnGRHS' :: HsMatchContext GhcRn +rnGRHS' :: HsMatchContext Name -> (Located (body GhcPs) -> RnM (Located (body GhcRn), FreeVars)) -> GRHS GhcPs (Located (body GhcPs)) -> RnM (GRHS GhcRn (Located (body GhcRn)), FreeVars) diff --git a/compiler/GHC/Rename/Expr.hs b/compiler/GHC/Rename/Expr.hs index eeecc5370f..f32c59cc7e 100644 --- a/compiler/GHC/Rename/Expr.hs +++ b/compiler/GHC/Rename/Expr.hs @@ -660,7 +660,7 @@ See Note [Deterministic UniqFM] to learn more about nondeterminism. -- | Rename some Stmts rnStmts :: Outputable (body GhcPs) - => HsStmtContext GhcRn + => HsStmtContext Name -> (Located (body GhcPs) -> RnM (Located (body GhcRn), FreeVars)) -- ^ How to rename the body of each statement (e.g. rnLExpr) -> [LStmt GhcPs (Located (body GhcPs))] @@ -674,10 +674,10 @@ rnStmts ctxt rnBody = rnStmtsWithPostProcessing ctxt rnBody noPostProcessStmts -- | like 'rnStmts' but applies a post-processing step to the renamed Stmts rnStmtsWithPostProcessing :: Outputable (body GhcPs) - => HsStmtContext GhcRn + => HsStmtContext Name -> (Located (body GhcPs) -> RnM (Located (body GhcRn), FreeVars)) -- ^ How to rename the body of each statement (e.g. rnLExpr) - -> (HsStmtContext GhcRn + -> (HsStmtContext Name -> [(LStmt GhcRn (Located (body GhcRn)), FreeVars)] -> RnM ([LStmt GhcRn (Located (body GhcRn))], FreeVars)) -- ^ postprocess the statements @@ -696,7 +696,7 @@ rnStmtsWithPostProcessing ctxt rnBody ppStmts stmts thing_inside -- | maybe rearrange statements according to the ApplicativeDo transformation postProcessStmtsForApplicativeDo - :: HsStmtContext GhcRn + :: HsStmtContext Name -> [(ExprLStmt GhcRn, FreeVars)] -> RnM ([ExprLStmt GhcRn], FreeVars) postProcessStmtsForApplicativeDo ctxt stmts @@ -717,14 +717,14 @@ postProcessStmtsForApplicativeDo ctxt stmts -- | strip the FreeVars annotations from statements noPostProcessStmts - :: HsStmtContext GhcRn + :: HsStmtContext Name -> [(LStmt GhcRn (Located (body GhcRn)), FreeVars)] -> RnM ([LStmt GhcRn (Located (body GhcRn))], FreeVars) noPostProcessStmts _ stmts = return (map fst stmts, emptyNameSet) rnStmtsWithFreeVars :: Outputable (body GhcPs) - => HsStmtContext GhcRn + => HsStmtContext Name -> (Located (body GhcPs) -> RnM (Located (body GhcRn), FreeVars)) -> [LStmt GhcPs (Located (body GhcPs))] -> ([Name] -> RnM (thing, FreeVars)) @@ -790,7 +790,7 @@ At one point we failed to make this distinction, leading to #11216. -} rnStmt :: Outputable (body GhcPs) - => HsStmtContext GhcRn + => HsStmtContext Name -> (Located (body GhcPs) -> RnM (Located (body GhcRn), FreeVars)) -- ^ How to rename the body of the statement -> LStmt GhcPs (Located (body GhcPs)) @@ -930,7 +930,7 @@ rnStmt ctxt _ (L loc (TransStmt { trS_stmts = stmts, trS_by = by, trS_form = for rnStmt _ _ (L _ ApplicativeStmt{}) _ = panic "rnStmt: ApplicativeStmt" -rnParallelStmts :: forall thing. HsStmtContext GhcRn +rnParallelStmts :: forall thing. HsStmtContext Name -> SyntaxExpr GhcRn -> [ParStmtBlock GhcPs GhcPs] -> ([Name] -> RnM (thing, FreeVars)) @@ -964,7 +964,7 @@ rnParallelStmts ctxt return_op segs thing_inside dupErr vs = addErr (text "Duplicate binding in parallel list comprehension for:" <+> quotes (ppr (NE.head vs))) -lookupQualifiedDoStmtName :: HsStmtContext GhcRn -> Name -> RnM (SyntaxExpr GhcRn, FreeVars) +lookupQualifiedDoStmtName :: HsStmtContext Name -> Name -> RnM (SyntaxExpr GhcRn, FreeVars) -- Like lookupStmtName, but respects QualifiedDo lookupQualifiedDoStmtName ctxt n = case qualifiedDoModuleName_maybe ctxt of @@ -972,7 +972,7 @@ lookupQualifiedDoStmtName ctxt n Just modName -> first (mkSyntaxExpr . nl_HsVar) <$> lookupNameWithQualifier n modName -lookupStmtName :: HsStmtContext GhcRn -> Name -> RnM (SyntaxExpr GhcRn, FreeVars) +lookupStmtName :: HsStmtContext Name -> Name -> RnM (SyntaxExpr GhcRn, FreeVars) -- Like lookupSyntax, but respects contexts lookupStmtName ctxt n | rebindableContext ctxt @@ -980,7 +980,7 @@ lookupStmtName ctxt n | otherwise = return (mkRnSyntaxExpr n, emptyFVs) -lookupStmtNamePoly :: HsStmtContext GhcRn -> Name -> RnM (HsExpr GhcRn, FreeVars) +lookupStmtNamePoly :: HsStmtContext Name -> Name -> RnM (HsExpr GhcRn, FreeVars) lookupStmtNamePoly ctxt name | rebindableContext ctxt = do { rebindable_on <- xoptM LangExt.RebindableSyntax @@ -996,7 +996,7 @@ lookupStmtNamePoly ctxt name -- | Is this a context where we respect RebindableSyntax? -- but ListComp are never rebindable -- Neither is ArrowExpr, which has its own desugarer in GHC.HsToCore.Arrows -rebindableContext :: HsStmtContext GhcRn -> Bool +rebindableContext :: HsStmtContext Name -> Bool rebindableContext ctxt = case ctxt of ListComp -> False ArrowExpr -> False @@ -1048,7 +1048,7 @@ type Segment stmts = (Defs, -- wrapper that does both the left- and right-hand sides rnRecStmtsAndThen :: Outputable (body GhcPs) => - HsStmtContext GhcRn + HsStmtContext Name -> (Located (body GhcPs) -> RnM (Located (body GhcRn), FreeVars)) -> [LStmt GhcPs (Located (body GhcPs))] @@ -1153,7 +1153,7 @@ rn_rec_stmts_lhs fix_env stmts -- right-hand-sides rn_rec_stmt :: (Outputable (body GhcPs)) => - HsStmtContext GhcRn + HsStmtContext Name -> (Located (body GhcPs) -> RnM (Located (body GhcRn), FreeVars)) -> [Name] -> (LStmtLR GhcRn GhcPs (Located (body GhcPs)), FreeVars) @@ -1212,7 +1212,7 @@ rn_rec_stmt _ _ _ stmt@(L _ (ApplicativeStmt {}), _) = pprPanic "rn_rec_stmt: ApplicativeStmt" (ppr stmt) rn_rec_stmts :: Outputable (body GhcPs) => - HsStmtContext GhcRn + HsStmtContext Name -> (Located (body GhcPs) -> RnM (Located (body GhcRn), FreeVars)) -> [Name] -> [(LStmtLR GhcRn GhcPs (Located (body GhcPs)), FreeVars)] @@ -1222,7 +1222,7 @@ rn_rec_stmts ctxt rnBody bndrs stmts ; return (concat segs_s) } --------------------------------------------- -segmentRecStmts :: SrcSpan -> HsStmtContext GhcRn +segmentRecStmts :: SrcSpan -> HsStmtContext Name -> Stmt GhcRn body -> [Segment (LStmt GhcRn body)] -> FreeVars -> ([LStmt GhcRn body], FreeVars) @@ -1326,7 +1326,7 @@ glom it together with the first two groups r <- x } -} -glomSegments :: HsStmtContext GhcRn +glomSegments :: HsStmtContext Name -> [Segment (LStmt GhcRn body)] -> [Segment [LStmt GhcRn body]] -- Each segment has a non-empty list of Stmts @@ -1537,7 +1537,7 @@ instance Outputable MonadNames where -- | rearrange a list of statements using ApplicativeDoStmt. See -- Note [ApplicativeDo]. rearrangeForApplicativeDo - :: HsStmtContext GhcRn + :: HsStmtContext Name -> [(ExprLStmt GhcRn, FreeVars)] -> RnM ([ExprLStmt GhcRn], FreeVars) @@ -1663,7 +1663,7 @@ mkStmtTreeOptimal stmts = -- ApplicativeStmt where necessary. stmtTreeToStmts :: MonadNames - -> HsStmtContext GhcRn + -> HsStmtContext Name -> ExprStmtTree -> [ExprLStmt GhcRn] -- ^ the "tail" -> FreeVars -- ^ free variables of the tail @@ -1940,7 +1940,7 @@ slurpIndependentStmts stmts = go [] [] emptyNameSet stmts -- it this way rather than try to ignore the return later in both the -- typechecker and the desugarer (I tried it that way first!). mkApplicativeStmt - :: HsStmtContext GhcRn + :: HsStmtContext Name -> [ApplicativeArg GhcRn] -- ^ The args -> Bool -- ^ True <=> need a join -> [ExprLStmt GhcRn] -- ^ The body statements @@ -2001,7 +2001,7 @@ isReturnApp monad_names (L _ e) = case e of ************************************************************************ -} -checkEmptyStmts :: HsStmtContext GhcRn -> RnM () +checkEmptyStmts :: HsStmtContext Name -> RnM () -- We've seen an empty sequence of Stmts... is that ok? checkEmptyStmts ctxt = unless (okEmpty ctxt) (addErr (emptyErr ctxt)) @@ -2010,13 +2010,13 @@ okEmpty :: HsStmtContext a -> Bool okEmpty (PatGuard {}) = True okEmpty _ = False -emptyErr :: HsStmtContext GhcRn -> SDoc +emptyErr :: HsStmtContext Name -> SDoc emptyErr (ParStmtCtxt {}) = text "Empty statement group in parallel comprehension" emptyErr (TransStmtCtxt {}) = text "Empty statement group preceding 'group' or 'then'" emptyErr ctxt = text "Empty" <+> pprStmtContext ctxt ---------------------- -checkLastStmt :: Outputable (body GhcPs) => HsStmtContext GhcRn +checkLastStmt :: Outputable (body GhcPs) => HsStmtContext Name -> LStmt GhcPs (Located (body GhcPs)) -> RnM (LStmt GhcPs (Located (body GhcPs))) checkLastStmt ctxt lstmt@(L loc stmt) @@ -2046,7 +2046,7 @@ checkLastStmt ctxt lstmt@(L loc stmt) = do { checkStmt ctxt lstmt; return lstmt } -- Checking when a particular Stmt is ok -checkStmt :: HsStmtContext GhcRn +checkStmt :: HsStmtContext Name -> LStmt GhcPs (Located (body GhcPs)) -> RnM () checkStmt ctxt (L _ stmt) @@ -2073,7 +2073,7 @@ emptyInvalid :: Validity -- Payload is the empty document emptyInvalid = NotValid Outputable.empty okStmt, okDoStmt, okCompStmt, okParStmt - :: DynFlags -> HsStmtContext GhcRn + :: DynFlags -> HsStmtContext Name -> Stmt GhcPs (Located (body GhcPs)) -> Validity -- Return Nothing if OK, (Just extra) if not ok -- The "extra" is an SDoc that is appended to a generic error message @@ -2155,7 +2155,7 @@ badIpBinds what binds --------- monadFailOp :: LPat GhcPs - -> HsStmtContext GhcRn + -> HsStmtContext Name -> RnM (FailOperator GhcRn, FreeVars) monadFailOp pat ctxt -- If the pattern is irrefutable (e.g.: wildcard, tuple, ~pat, etc.) diff --git a/compiler/GHC/Rename/Expr.hs-boot b/compiler/GHC/Rename/Expr.hs-boot index cc52d45e82..d885c1b239 100644 --- a/compiler/GHC/Rename/Expr.hs-boot +++ b/compiler/GHC/Rename/Expr.hs-boot @@ -10,7 +10,7 @@ rnLExpr :: LHsExpr GhcPs -> RnM (LHsExpr GhcRn, FreeVars) rnStmts :: --forall thing body. - Outputable (body GhcPs) => HsStmtContext GhcRn + Outputable (body GhcPs) => HsStmtContext Name -> (Located (body GhcPs) -> RnM (Located (body GhcRn), FreeVars)) -> [LStmt GhcPs (Located (body GhcPs))] -> ([Name] -> RnM (thing, FreeVars)) diff --git a/compiler/GHC/Rename/Pat.hs b/compiler/GHC/Rename/Pat.hs index 72058a2512..5e815a9019 100644 --- a/compiler/GHC/Rename/Pat.hs +++ b/compiler/GHC/Rename/Pat.hs @@ -318,7 +318,7 @@ There are various entry points to renaming patterns, depending on -- * local namemaker -- * unused and duplicate checking -- * no fixities -rnPats :: HsMatchContext GhcRn -- for error messages +rnPats :: HsMatchContext Name -- for error messages -> [LPat GhcPs] -> ([LPat GhcRn] -> RnM (a, FreeVars)) -> RnM (a, FreeVars) @@ -346,7 +346,7 @@ rnPats ctxt pats thing_inside where doc_pat = text "In" <+> pprMatchContext ctxt -rnPat :: HsMatchContext GhcRn -- for error messages +rnPat :: HsMatchContext Name -- for error messages -> LPat GhcPs -> (LPat GhcRn -> RnM (a, FreeVars)) -> RnM (a, FreeVars) -- Variables bound by pattern do not diff --git a/compiler/GHC/Tc/Deriv/Functor.hs b/compiler/GHC/Tc/Deriv/Functor.hs index 324e51370c..09abdda55d 100644 --- a/compiler/GHC/Tc/Deriv/Functor.hs +++ b/compiler/GHC/Tc/Deriv/Functor.hs @@ -248,7 +248,7 @@ gen_Functor_binds loc tycon tycon_args -- Con a1 a2 ... -> Con (f1 a1) (f2 a2) ... match_for_con :: Monad m - => HsMatchContext GhcPs + => HsMatchContext RdrName -> [LPat GhcPs] -> DataCon -> [LHsExpr GhcPs -> m (LHsExpr GhcPs)] -> m (LMatch GhcPs (LHsExpr GhcPs)) @@ -602,7 +602,7 @@ mkSimpleLam2 lam = -- constructor @con@ and its arguments. The RHS folds (with @fold@) over @con@ -- and its arguments, applying an expression (from @insides@) to each of the -- respective arguments of @con@. -mkSimpleConMatch :: Monad m => HsMatchContext GhcPs +mkSimpleConMatch :: Monad m => HsMatchContext RdrName -> (RdrName -> [a] -> m (LHsExpr GhcPs)) -> [LPat GhcPs] -> DataCon @@ -638,7 +638,7 @@ mkSimpleConMatch ctxt fold extra_pats con insides = do -- -- See Note [Generated code for DeriveFoldable and DeriveTraversable] mkSimpleConMatch2 :: Monad m - => HsMatchContext GhcPs + => HsMatchContext RdrName -> (LHsExpr GhcPs -> [LHsExpr GhcPs] -> m (LHsExpr GhcPs)) -> [LPat GhcPs] diff --git a/compiler/GHC/Tc/Gen/Arrow.hs b/compiler/GHC/Tc/Gen/Arrow.hs index 82d405f0bb..57a136155a 100644 --- a/compiler/GHC/Tc/Gen/Arrow.hs +++ b/compiler/GHC/Tc/Gen/Arrow.hs @@ -32,6 +32,7 @@ import GHC.Tc.Types.Origin import GHC.Tc.Types.Evidence import GHC.Core.Multiplicity import GHC.Types.Id( mkLocalId ) +import GHC.Types.Name import GHC.Tc.Utils.Instantiate import GHC.Builtin.Types import GHC.Types.Var.Set @@ -270,7 +271,7 @@ tc_cmd env ; return (mkHsCmdWrap (mkWpCastN co) cmd') } where n_pats = length pats - match_ctxt = (LambdaExpr :: HsMatchContext GhcRn) -- Maybe KappaExpr? + match_ctxt = (LambdaExpr :: HsMatchContext Name) -- Maybe KappaExpr? pg_ctxt = PatGuard match_ctxt tc_grhss (GRHSs x grhss (L l binds)) stk_ty res_ty diff --git a/compiler/GHC/Tc/Gen/Match.hs b/compiler/GHC/Tc/Gen/Match.hs index 38e400419a..eee8e91053 100644 --- a/compiler/GHC/Tc/Gen/Match.hs +++ b/compiler/GHC/Tc/Gen/Match.hs @@ -180,7 +180,7 @@ tcGRHSsPat grhss res_ty ********************************************************************* -} data TcMatchCtxt body -- c.f. TcStmtCtxt, also in this module - = MC { mc_what :: HsMatchContext GhcRn, -- What kind of thing this is + = MC { mc_what :: HsMatchContext Name, -- What kind of thing this is mc_body :: Located (body GhcRn) -- Type checker for a body of -- an alternative -> ExpRhoType @@ -280,7 +280,7 @@ tcGRHS ctxt res_ty (GRHS _ guards rhs) ************************************************************************ -} -tcDoStmts :: HsStmtContext GhcRn +tcDoStmts :: HsStmtContext Name -> Located [LStmt GhcRn (LHsExpr GhcRn)] -> ExpRhoType -> TcM (HsExpr GhcTc) -- Returns a HsDo @@ -327,13 +327,13 @@ type TcExprStmtChecker = TcStmtChecker HsExpr ExpRhoType type TcCmdStmtChecker = TcStmtChecker HsCmd TcRhoType type TcStmtChecker body rho_type - = forall thing. HsStmtContext GhcRn + = forall thing. HsStmtContext Name -> Stmt GhcRn (Located (body GhcRn)) -> rho_type -- Result type for comprehension -> (rho_type -> TcM thing) -- Checker for what follows the stmt -> TcM (Stmt GhcTc (Located (body GhcTc)), thing) -tcStmts :: (Outputable (body GhcRn)) => HsStmtContext GhcRn +tcStmts :: (Outputable (body GhcRn)) => HsStmtContext Name -> TcStmtChecker body rho_type -- NB: higher-rank type -> [LStmt GhcRn (Located (body GhcRn))] -> rho_type @@ -343,7 +343,7 @@ tcStmts ctxt stmt_chk stmts res_ty const (return ()) ; return stmts' } -tcStmtsAndThen :: (Outputable (body GhcRn)) => HsStmtContext GhcRn +tcStmtsAndThen :: (Outputable (body GhcRn)) => HsStmtContext Name -> TcStmtChecker body rho_type -- NB: higher-rank type -> [LStmt GhcRn (Located (body GhcRn))] -> rho_type @@ -980,7 +980,7 @@ join :: tn -> res_ty -} tcApplicativeStmts - :: HsStmtContext GhcRn + :: HsStmtContext Name -> [(SyntaxExpr GhcRn, ApplicativeArg GhcRn)] -> ExpRhoType -- rhs_ty -> (TcRhoType -> TcM t) -- thing_inside diff --git a/compiler/GHC/Tc/Gen/Pat.hs b/compiler/GHC/Tc/Gen/Pat.hs index 27b2b1358b..d1b4b29561 100644 --- a/compiler/GHC/Tc/Gen/Pat.hs +++ b/compiler/GHC/Tc/Gen/Pat.hs @@ -94,7 +94,7 @@ tcLetPat sig_fn no_gen pat pat_ty thing_inside ; tc_lpat pat_ty penv pat thing_inside } ----------------- -tcPats :: HsMatchContext GhcRn +tcPats :: HsMatchContext Name -> [LPat GhcRn] -- Patterns, -> [Scaled ExpSigmaType] -- and their types -> TcM a -- and the checker for the body @@ -116,7 +116,7 @@ tcPats ctxt pats pat_tys thing_inside where penv = PE { pe_lazy = False, pe_ctxt = LamPat ctxt, pe_orig = PatOrigin } -tcInferPat :: HsMatchContext GhcRn -> LPat GhcRn +tcInferPat :: HsMatchContext Name -> LPat GhcRn -> TcM a -> TcM ((LPat GhcTc, a), TcSigmaType) tcInferPat ctxt pat thing_inside @@ -125,14 +125,14 @@ tcInferPat ctxt pat thing_inside where penv = PE { pe_lazy = False, pe_ctxt = LamPat ctxt, pe_orig = PatOrigin } -tcCheckPat :: HsMatchContext GhcRn +tcCheckPat :: HsMatchContext Name -> LPat GhcRn -> Scaled TcSigmaType -> TcM a -- Checker for body -> TcM (LPat GhcTc, a) tcCheckPat ctxt = tcCheckPat_O ctxt PatOrigin -- | A variant of 'tcPat' that takes a custom origin -tcCheckPat_O :: HsMatchContext GhcRn +tcCheckPat_O :: HsMatchContext Name -> CtOrigin -- ^ origin to use if the type needs inst'ing -> LPat GhcRn -> Scaled TcSigmaType -> TcM a -- Checker for body @@ -159,7 +159,7 @@ data PatEnv data PatCtxt = LamPat -- Used for lambdas, case etc - (HsMatchContext GhcRn) + (HsMatchContext Name) | LetPat -- Used only for let(rec) pattern bindings -- See Note [Typing patterns in pattern bindings] diff --git a/compiler/GHC/Tc/Types/Origin.hs b/compiler/GHC/Tc/Types/Origin.hs index d836b8d947..f14434a60b 100644 --- a/compiler/GHC/Tc/Types/Origin.hs +++ b/compiler/GHC/Tc/Types/Origin.hs @@ -201,7 +201,7 @@ data SkolemInfo | FamInstSkol -- Bound at a family instance decl | PatSkol -- An existential type variable bound by a pattern for ConLike -- a data constructor with an existential type. - (HsMatchContext GhcRn) + (HsMatchContext Name) -- e.g. data T = forall a. Eq a => MkT a -- f (MkT x) = ... -- The pattern MkT x will allocate an existential type diff --git a/compiler/GHC/ThToHs.hs b/compiler/GHC/ThToHs.hs index bdc0203c90..53b27b5189 100644 --- a/compiler/GHC/ThToHs.hs +++ b/compiler/GHC/ThToHs.hs @@ -867,7 +867,7 @@ cvtLocalDecs doc ds ((_:_), (_:_)) -> failWith (text "Implicit parameters mixed with other bindings") -cvtClause :: HsMatchContext GhcPs +cvtClause :: HsMatchContext RdrName -> TH.Clause -> CvtM (Hs.LMatch GhcPs (LHsExpr GhcPs)) cvtClause ctxt (Clause ps body wheres) = do { ps' <- cvtPats ps @@ -1140,7 +1140,7 @@ cvtOpApp x op y -- Do notation and statements ------------------------------------- -cvtHsDo :: HsStmtContext GhcRn -> [TH.Stmt] -> CvtM (HsExpr GhcPs) +cvtHsDo :: HsStmtContext Name.Name -> [TH.Stmt] -> CvtM (HsExpr GhcPs) cvtHsDo do_or_lc stmts | null stmts = failWith (text "Empty stmt list in do-block") | otherwise @@ -1173,7 +1173,7 @@ cvtStmt (TH.ParS dss) = do { dss' <- mapM cvt_one dss ; return (ParStmtBlock noExtField ds' undefined noSyntaxExpr) } cvtStmt (TH.RecS ss) = do { ss' <- mapM cvtStmt ss; returnL (mkRecStmt ss') } -cvtMatch :: HsMatchContext GhcPs +cvtMatch :: HsMatchContext RdrName -> TH.Match -> CvtM (Hs.LMatch GhcPs (LHsExpr GhcPs)) cvtMatch ctxt (TH.Match p body decs) = do { p' <- cvtPat p |