summaryrefslogtreecommitdiff
path: root/compiler/deSugar
diff options
context:
space:
mode:
authorAlan Zimmerman <alan.zimm@gmail.com>2017-05-19 14:56:09 +0200
committerAlan Zimmerman <alan.zimm@gmail.com>2017-06-06 00:16:20 +0200
commit8e6ec0fa7431b0454b09c0011a615f0845df1198 (patch)
treed6b3604e0ceac3d81d0510669f7ccce9a2bf3ae2 /compiler/deSugar
parentc9eb4385aad248118650725b7b699bb97ee21c0d (diff)
downloadhaskell-8e6ec0fa7431b0454b09c0011a615f0845df1198.tar.gz
Udate hsSyn AST to use Trees that Grow
Summary: See https://ghc.haskell.org/trac/ghc/wiki/ImplementingTreesThatGrow This commit prepares the ground for a full extensible AST, by replacing the type parameter for the hsSyn data types with a set of indices into type families, data GhcPs -- ^ Index for GHC parser output data GhcRn -- ^ Index for GHC renamer output data GhcTc -- ^ Index for GHC typechecker output These are now used instead of `RdrName`, `Name` and `Id`/`TcId`/`Var` Where the original name type is required in a polymorphic context, this is accessible via the IdP type family, defined as type family IdP p type instance IdP GhcPs = RdrName type instance IdP GhcRn = Name type instance IdP GhcTc = Id These types are declared in the new 'hsSyn/HsExtension.hs' module. To gain a better understanding of the extension mechanism, it has been applied to `HsLit` only, also replacing the `SourceText` fields in them with extension types. To preserve extension generality, a type class is introduced to capture the `SourceText` interface, which must be honoured by all of the extension points which originally had a `SourceText`. The class is defined as class HasSourceText a where -- Provide setters to mimic existing constructors noSourceText :: a sourceText :: String -> a setSourceText :: SourceText -> a getSourceText :: a -> SourceText And the constraint is captured in `SourceTextX`, which is a constraint type listing all the extension points that make use of the class. Updating Haddock submodule to match. Test Plan: ./validate Reviewers: simonpj, shayan-najd, goldfire, austin, bgamari Subscribers: rwbarton, thomie, mpickering Differential Revision: https://phabricator.haskell.org/D3609
Diffstat (limited to 'compiler/deSugar')
-rw-r--r--compiler/deSugar/Check.hs66
-rw-r--r--compiler/deSugar/Coverage.hs122
-rw-r--r--compiler/deSugar/Desugar.hs7
-rw-r--r--compiler/deSugar/DsArrows.hs71
-rw-r--r--compiler/deSugar/DsBinds.hs16
-rw-r--r--compiler/deSugar/DsExpr.hs41
-rw-r--r--compiler/deSugar/DsExpr.hs-boot16
-rw-r--r--compiler/deSugar/DsForeign.hs10
-rw-r--r--compiler/deSugar/DsGRHSs.hs18
-rw-r--r--compiler/deSugar/DsListComp.hs59
-rw-r--r--compiler/deSugar/DsMeta.hs231
-rw-r--r--compiler/deSugar/DsMonad.hs2
-rw-r--r--compiler/deSugar/DsUtils.hs29
-rw-r--r--compiler/deSugar/Match.hs43
-rw-r--r--compiler/deSugar/Match.hs-boot9
-rw-r--r--compiler/deSugar/MatchCon.hs8
-rw-r--r--compiler/deSugar/MatchLit.hs40
-rw-r--r--compiler/deSugar/PmExpr.hs12
18 files changed, 417 insertions, 383 deletions
diff --git a/compiler/deSugar/Check.hs b/compiler/deSugar/Check.hs
index 8234cccb5c..19bdba658f 100644
--- a/compiler/deSugar/Check.hs
+++ b/compiler/deSugar/Check.hs
@@ -134,7 +134,7 @@ data PmPat :: PatTy -> * where
, pm_con_dicts :: [EvVar]
, pm_con_args :: [PmPat t] } -> PmPat t
-- For PmCon arguments' meaning see @ConPatOut@ in hsSyn/HsPat.hs
- PmVar :: { pm_var_id :: Id } -> PmPat t
+ PmVar :: { pm_var_id :: Id } -> PmPat t
PmLit :: { pm_lit_lit :: PmLit } -> PmPat t -- See Note [Literals in PmPat]
PmNLit :: { pm_lit_id :: Id
, pm_lit_not :: [PmLit] } -> PmPat 'VA
@@ -254,9 +254,9 @@ instance Monoid PartialResult where
data PmResult =
PmResult {
pmresultProvenance :: Provenance
- , pmresultRedundant :: [Located [LPat Id]]
+ , pmresultRedundant :: [Located [LPat GhcTc]]
, pmresultUncovered :: UncoveredCandidates
- , pmresultInaccessible :: [Located [LPat Id]] }
+ , pmresultInaccessible :: [Located [LPat GhcTc]] }
-- | Either a list of patterns that are not covered, or their type, in case we
-- have no patterns at hand. Not having patterns at hand can arise when
@@ -289,7 +289,7 @@ uncoveredWithTy ty = PmResult FromBuiltin [] (TypeOfUncovered ty) []
-}
-- | Check a single pattern binding (let)
-checkSingle :: DynFlags -> DsMatchContext -> Id -> Pat Id -> DsM ()
+checkSingle :: DynFlags -> DsMatchContext -> Id -> Pat GhcTc -> DsM ()
checkSingle dflags ctxt@(DsMatchContext _ locn) var p = do
tracePmD "checkSingle" (vcat [ppr ctxt, ppr var, ppr p])
mb_pm_res <- tryM (getResult (checkSingle' locn var p))
@@ -298,7 +298,7 @@ checkSingle dflags ctxt@(DsMatchContext _ locn) var p = do
Right res -> dsPmWarn dflags ctxt res
-- | Check a single pattern binding (let)
-checkSingle' :: SrcSpan -> Id -> Pat Id -> PmM PmResult
+checkSingle' :: SrcSpan -> Id -> Pat GhcTc -> PmM PmResult
checkSingle' locn var p = do
liftD resetPmIterDs -- set the iter-no to zero
fam_insts <- liftD dsGetFamInstEnvs
@@ -316,7 +316,7 @@ checkSingle' locn var p = do
-- | Check a matchgroup (case, functions, etc.)
checkMatches :: DynFlags -> DsMatchContext
- -> [Id] -> [LMatch Id (LHsExpr Id)] -> DsM ()
+ -> [Id] -> [LMatch GhcTc (LHsExpr GhcTc)] -> DsM ()
checkMatches dflags ctxt vars matches = do
tracePmD "checkMatches" (hang (vcat [ppr ctxt
, ppr vars
@@ -334,7 +334,7 @@ checkMatches dflags ctxt vars matches = do
-- | Check a matchgroup (case, functions, etc.). To be called on a non-empty
-- list of matches. For empty case expressions, use checkEmptyCase' instead.
-checkMatches' :: [Id] -> [LMatch Id (LHsExpr Id)] -> PmM PmResult
+checkMatches' :: [Id] -> [LMatch GhcTc (LHsExpr GhcTc)] -> PmM PmResult
checkMatches' vars matches
| null matches = panic "checkMatches': EmptyCase"
| otherwise = do
@@ -348,11 +348,11 @@ checkMatches' vars matches
, pmresultUncovered = UncoveredPatterns us
, pmresultInaccessible = map hsLMatchToLPats ds }
where
- go :: [LMatch Id (LHsExpr Id)] -> Uncovered
+ go :: [LMatch GhcTc (LHsExpr GhcTc)] -> Uncovered
-> PmM (Provenance
- , [LMatch Id (LHsExpr Id)]
+ , [LMatch GhcTc (LHsExpr GhcTc)]
, Uncovered
- , [LMatch Id (LHsExpr Id)])
+ , [LMatch GhcTc (LHsExpr GhcTc)])
go [] missing = return (mempty, [], missing, [])
go (m:ms) missing = do
tracePm "checMatches': go" (ppr m $$ ppr missing)
@@ -544,14 +544,14 @@ mkListPatVec ty xs ys = [PmCon { pm_con_con = RealDataCon consDataCon
{-# INLINE mkListPatVec #-}
-- | Create a (non-overloaded) literal pattern
-mkLitPattern :: HsLit -> Pattern
+mkLitPattern :: HsLit GhcTc -> Pattern
mkLitPattern lit = PmLit { pm_lit_lit = PmSLit lit }
{-# INLINE mkLitPattern #-}
-- -----------------------------------------------------------------------
-- * Transform (Pat Id) into of (PmPat Id)
-translatePat :: FamInstEnvs -> Pat Id -> DsM PatVec
+translatePat :: FamInstEnvs -> Pat GhcTc -> DsM PatVec
translatePat fam_insts pat = case pat of
WildPat ty -> mkPmVars [ty]
VarPat id -> return [PmVar (unLoc id)]
@@ -661,15 +661,16 @@ translatePat fam_insts pat = case pat of
-- | Translate an overloaded literal (see `tidyNPat' in deSugar/MatchLit.hs)
translateNPat :: FamInstEnvs
- -> HsOverLit Id -> Maybe (SyntaxExpr Id) -> Type -> DsM PatVec
+ -> HsOverLit GhcTc -> Maybe (SyntaxExpr GhcTc) -> Type
+ -> DsM PatVec
translateNPat fam_insts (OverLit val False _ ty) mb_neg outer_ty
| not type_change, isStringTy ty, HsIsString src s <- val, Nothing <- mb_neg
= translatePat fam_insts (LitPat (HsString src s))
| not type_change, isIntTy ty, HsIntegral i <- val
= translatePat fam_insts
(LitPat $ case mb_neg of
- Nothing -> HsInt i
- Just _ -> HsInt (negateIntegralLit i))
+ Nothing -> HsInt def i
+ Just _ -> HsInt def (negateIntegralLit i))
| not type_change, isWordTy ty, HsIntegral i <- val
= translatePat fam_insts
(LitPat $ case mb_neg of
@@ -684,12 +685,12 @@ translateNPat _ ol mb_neg _
-- | Translate a list of patterns (Note: each pattern is translated
-- to a pattern vector but we do not concatenate the results).
-translatePatVec :: FamInstEnvs -> [Pat Id] -> DsM [PatVec]
+translatePatVec :: FamInstEnvs -> [Pat GhcTc] -> DsM [PatVec]
translatePatVec fam_insts pats = mapM (translatePat fam_insts) pats
-- | Translate a constructor pattern
translateConPatVec :: FamInstEnvs -> [Type] -> [TyVar]
- -> ConLike -> HsConPatDetails Id -> DsM PatVec
+ -> ConLike -> HsConPatDetails GhcTc -> DsM PatVec
translateConPatVec fam_insts _univ_tys _ex_tvs _ (PrefixCon ps)
= concat <$> translatePatVec fam_insts (map unLoc ps)
translateConPatVec fam_insts _univ_tys _ex_tvs _ (InfixCon p1 p2)
@@ -744,13 +745,14 @@ translateConPatVec fam_insts univ_tys ex_tvs c (RecCon (HsRecFields fs _))
| otherwise = subsetOf (x:xs) ys
-- Translate a single match
-translateMatch :: FamInstEnvs -> LMatch Id (LHsExpr Id) -> DsM (PatVec,[PatVec])
+translateMatch :: FamInstEnvs -> LMatch GhcTc (LHsExpr GhcTc)
+ -> DsM (PatVec,[PatVec])
translateMatch fam_insts (L _ (Match _ lpats _ grhss)) = do
pats' <- concat <$> translatePatVec fam_insts pats
guards' <- mapM (translateGuards fam_insts) guards
return (pats', guards')
where
- extractGuards :: LGRHS Id (LHsExpr Id) -> [GuardStmt Id]
+ extractGuards :: LGRHS GhcTc (LHsExpr GhcTc) -> [GuardStmt GhcTc]
extractGuards (L _ (GRHS gs _)) = map unLoc gs
pats = map unLoc lpats
@@ -760,7 +762,7 @@ translateMatch fam_insts (L _ (Match _ lpats _ grhss)) = do
-- * Transform source guards (GuardStmt Id) to PmPats (Pattern)
-- | Translate a list of guard statements to a pattern vector
-translateGuards :: FamInstEnvs -> [GuardStmt Id] -> DsM PatVec
+translateGuards :: FamInstEnvs -> [GuardStmt GhcTc] -> DsM PatVec
translateGuards fam_insts guards = do
all_guards <- concat <$> mapM (translateGuard fam_insts) guards
return (replace_unhandled all_guards)
@@ -800,7 +802,7 @@ cantFailPattern (PmGrd pv _e)
cantFailPattern _ = False
-- | Translate a guard statement to Pattern
-translateGuard :: FamInstEnvs -> GuardStmt Id -> DsM PatVec
+translateGuard :: FamInstEnvs -> GuardStmt GhcTc -> DsM PatVec
translateGuard fam_insts guard = case guard of
BodyStmt e _ _ _ -> translateBoolGuard e
LetStmt binds -> translateLet (unLoc binds)
@@ -812,17 +814,17 @@ translateGuard fam_insts guard = case guard of
ApplicativeStmt {} -> panic "translateGuard ApplicativeLastStmt"
-- | Translate let-bindings
-translateLet :: HsLocalBinds Id -> DsM PatVec
+translateLet :: HsLocalBinds GhcTc -> DsM PatVec
translateLet _binds = return []
-- | Translate a pattern guard
-translateBind :: FamInstEnvs -> LPat Id -> LHsExpr Id -> DsM PatVec
+translateBind :: FamInstEnvs -> LPat GhcTc -> LHsExpr GhcTc -> DsM PatVec
translateBind fam_insts (L _ p) e = do
ps <- translatePat fam_insts p
return [mkGuard ps (unLoc e)]
-- | Translate a boolean guard
-translateBoolGuard :: LHsExpr Id -> DsM PatVec
+translateBoolGuard :: LHsExpr GhcTc -> DsM PatVec
translateBoolGuard e
| isJust (isTrueLHsExpr e) = return []
-- The formal thing to do would be to generate (True <- True)
@@ -996,7 +998,7 @@ mkOneConFull x con = do
-- * More smart constructors and fresh variable generation
-- | Create a guard pattern
-mkGuard :: PatVec -> HsExpr Id -> Pattern
+mkGuard :: PatVec -> HsExpr GhcTc -> Pattern
mkGuard pv e
| all cantFailPattern pv = PmGrd pv expr
| PmExprOther {} <- expr = fake_pat
@@ -1041,7 +1043,7 @@ mkPmId ty = getUniqueM >>= \unique ->
-- | Generate a fresh term variable of a given and return it in two forms:
-- * A variable pattern
-- * A variable expression
-mkPmId2Forms :: Type -> DsM (Pattern, LHsExpr Id)
+mkPmId2Forms :: Type -> DsM (Pattern, LHsExpr GhcTc)
mkPmId2Forms ty = do
x <- mkPmId ty
return (PmVar x, noLoc (HsVar (noLoc x)))
@@ -1508,9 +1510,9 @@ these constraints.
-- When we go deeper to check e.g. e1 we record two equalities:
-- (x ~ y), where y is the initial uncovered when checking (p1; .. ; pn)
-- and (x ~ p1).
-genCaseTmCs2 :: Maybe (LHsExpr Id) -- Scrutinee
- -> [Pat Id] -- LHS (should have length 1)
- -> [Id] -- MatchVars (should have length 1)
+genCaseTmCs2 :: Maybe (LHsExpr GhcTc) -- Scrutinee
+ -> [Pat GhcTc] -- LHS (should have length 1)
+ -> [Id] -- MatchVars (should have length 1)
-> DsM (Bag SimpleEq)
genCaseTmCs2 Nothing _ _ = return emptyBag
genCaseTmCs2 (Just scr) [p] [var] = do
@@ -1524,7 +1526,7 @@ genCaseTmCs2 _ _ _ = panic "genCaseTmCs2: HsCase"
-- case x of { matches }
-- When checking matches we record that (x ~ y) where y is the initial
-- uncovered. All matches will have to satisfy this equality.
-genCaseTmCs1 :: Maybe (LHsExpr Id) -> [Id] -> Bag SimpleEq
+genCaseTmCs1 :: Maybe (LHsExpr GhcTc) -> [Id] -> Bag SimpleEq
genCaseTmCs1 Nothing _ = emptyBag
genCaseTmCs1 (Just scr) [var] = unitBag (var, lhsExprToPmExpr scr)
genCaseTmCs1 _ _ = panic "genCaseTmCs1: HsCase"
@@ -1742,11 +1744,11 @@ pp_context singular (DsMatchContext kind _loc) msg rest_of_msg_fun
\ pp -> ppr fun <+> pp)
_ -> (pprMatchContext kind, \ pp -> pp)
-ppr_pats :: HsMatchContext Name -> [Pat Id] -> SDoc
+ppr_pats :: HsMatchContext Name -> [Pat GhcTc] -> SDoc
ppr_pats kind pats
= sep [sep (map ppr pats), matchSeparator kind, text "..."]
-ppr_eqn :: (SDoc -> SDoc) -> HsMatchContext Name -> [LPat Id] -> SDoc
+ppr_eqn :: (SDoc -> SDoc) -> HsMatchContext Name -> [LPat GhcTc] -> SDoc
ppr_eqn prefixF kind eqn = prefixF (ppr_pats kind (map unLoc eqn))
ppr_constraint :: (SDoc,[PmLit]) -> SDoc
diff --git a/compiler/deSugar/Coverage.hs b/compiler/deSugar/Coverage.hs
index 92002bf793..16537bd7a5 100644
--- a/compiler/deSugar/Coverage.hs
+++ b/compiler/deSugar/Coverage.hs
@@ -68,8 +68,8 @@ addTicksToBinds
-- isExportedId doesn't work yet (the desugarer
-- hasn't set it), so we have to work from this set.
-> [TyCon] -- Type constructor in this module
- -> LHsBinds Id
- -> IO (LHsBinds Id, HpcInfo, Maybe ModBreaks)
+ -> LHsBinds GhcTc
+ -> IO (LHsBinds GhcTc, HpcInfo, Maybe ModBreaks)
addTicksToBinds hsc_env mod mod_loc exports tyCons binds
| let dflags = hsc_dflags hsc_env
@@ -118,7 +118,7 @@ addTicksToBinds hsc_env mod mod_loc exports tyCons binds
| otherwise = return (binds, emptyHpcInfo False, Nothing)
-guessSourceFile :: LHsBinds Id -> FilePath -> FilePath
+guessSourceFile :: LHsBinds GhcTc -> FilePath -> FilePath
guessSourceFile binds orig_file =
-- Try look for a file generated from a .hsc file to a
-- .hs file, by peeking ahead.
@@ -252,10 +252,10 @@ shouldTickPatBind density top_lev
-- -----------------------------------------------------------------------------
-- Adding ticks to bindings
-addTickLHsBinds :: LHsBinds Id -> TM (LHsBinds Id)
+addTickLHsBinds :: LHsBinds GhcTc -> TM (LHsBinds GhcTc)
addTickLHsBinds = mapBagM addTickLHsBind
-addTickLHsBind :: LHsBind Id -> TM (LHsBind Id)
+addTickLHsBind :: LHsBind GhcTc -> TM (LHsBind GhcTc)
addTickLHsBind (L pos bind@(AbsBinds { abs_binds = binds,
abs_exports = abs_exports })) = do
withEnv add_exports $ do
@@ -419,7 +419,7 @@ bindTick density name pos fvs = do
-- Decorate an LHsExpr with ticks
-- selectively add ticks to interesting expressions
-addTickLHsExpr :: LHsExpr Id -> TM (LHsExpr Id)
+addTickLHsExpr :: LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExpr e@(L pos e0) = do
d <- getDensity
case d of
@@ -435,7 +435,7 @@ addTickLHsExpr e@(L pos e0) = do
-- We always consider these to be breakpoints, unless the expression is a 'let'
-- (because the body will definitely have a tick somewhere). ToDo: perhaps
-- we should treat 'case' and 'if' the same way?
-addTickLHsExprRHS :: LHsExpr Id -> TM (LHsExpr Id)
+addTickLHsExprRHS :: LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExprRHS e@(L pos e0) = do
d <- getDensity
case d of
@@ -452,7 +452,7 @@ addTickLHsExprRHS e@(L pos e0) = do
-- let binds in [], ( [] )
-- we never tick these if we're doing HPC, but otherwise
-- we treat it like an ordinary expression.
-addTickLHsExprEvalInner :: LHsExpr Id -> TM (LHsExpr Id)
+addTickLHsExprEvalInner :: LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExprEvalInner e = do
d <- getDensity
case d of
@@ -464,7 +464,7 @@ addTickLHsExprEvalInner e = do
-- want to tick the body, even if it is not a redex. See test
-- break012. This gives the user the opportunity to inspect the
-- values of the let-bound variables.
-addTickLHsExprLetBody :: LHsExpr Id -> TM (LHsExpr Id)
+addTickLHsExprLetBody :: LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExprLetBody e@(L pos e0) = do
d <- getDensity
case d of
@@ -478,32 +478,32 @@ addTickLHsExprLetBody e@(L pos e0) = do
-- version of addTick that does not actually add a tick,
-- because the scope of this tick is completely subsumed by
-- another.
-addTickLHsExprNever :: LHsExpr Id -> TM (LHsExpr Id)
+addTickLHsExprNever :: LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExprNever (L pos e0) = do
e1 <- addTickHsExpr e0
return $ L pos e1
-- general heuristic: expressions which do not denote values are good
-- break points
-isGoodBreakExpr :: HsExpr Id -> Bool
+isGoodBreakExpr :: HsExpr GhcTc -> Bool
isGoodBreakExpr (HsApp {}) = True
isGoodBreakExpr (HsAppTypeOut {}) = True
isGoodBreakExpr (OpApp {}) = True
isGoodBreakExpr _other = False
-isCallSite :: HsExpr Id -> Bool
+isCallSite :: HsExpr GhcTc -> Bool
isCallSite HsApp{} = True
isCallSite HsAppTypeOut{} = True
isCallSite OpApp{} = True
isCallSite _ = False
-addTickLHsExprOptAlt :: Bool -> LHsExpr Id -> TM (LHsExpr Id)
+addTickLHsExprOptAlt :: Bool -> LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickLHsExprOptAlt oneOfMany (L pos e0)
= ifDensity TickForCoverage
(allocTickBox (ExpBox oneOfMany) False False pos $ addTickHsExpr e0)
(addTickLHsExpr (L pos e0))
-addBinTickLHsExpr :: (Bool -> BoxLabel) -> LHsExpr Id -> TM (LHsExpr Id)
+addBinTickLHsExpr :: (Bool -> BoxLabel) -> LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addBinTickLHsExpr boxLabel (L pos e0)
= ifDensity TickForCoverage
(allocBinTickBox boxLabel pos $ addTickHsExpr e0)
@@ -515,7 +515,7 @@ addBinTickLHsExpr boxLabel (L pos e0)
-- (Whether to put a tick around the whole expression was already decided,
-- in the addTickLHsExpr family of functions.)
-addTickHsExpr :: HsExpr Id -> TM (HsExpr Id)
+addTickHsExpr :: HsExpr GhcTc -> TM (HsExpr GhcTc)
addTickHsExpr e@(HsVar (L _ id)) = do freeVar id; return e
addTickHsExpr (HsUnboundVar {}) = panic "addTickHsExpr.HsUnboundVar"
addTickHsExpr e@(HsConLikeOut con)
@@ -668,24 +668,27 @@ addTickHsExpr (ExprWithTySigOut e ty) =
-- Others should never happen in expression content.
addTickHsExpr e = pprPanic "addTickHsExpr" (ppr e)
-addTickTupArg :: LHsTupArg Id -> TM (LHsTupArg Id)
+addTickTupArg :: LHsTupArg GhcTc -> TM (LHsTupArg GhcTc)
addTickTupArg (L l (Present e)) = do { e' <- addTickLHsExpr e
; return (L l (Present e')) }
addTickTupArg (L l (Missing ty)) = return (L l (Missing ty))
-addTickMatchGroup :: Bool{-is lambda-} -> MatchGroup Id (LHsExpr Id) -> TM (MatchGroup Id (LHsExpr Id))
+addTickMatchGroup :: Bool{-is lambda-} -> MatchGroup GhcTc (LHsExpr GhcTc)
+ -> TM (MatchGroup GhcTc (LHsExpr GhcTc))
addTickMatchGroup is_lam mg@(MG { mg_alts = L l matches }) = do
let isOneOfMany = matchesOneOfMany matches
matches' <- mapM (liftL (addTickMatch isOneOfMany is_lam)) matches
return $ mg { mg_alts = L l matches' }
-addTickMatch :: Bool -> Bool -> Match Id (LHsExpr Id) -> TM (Match Id (LHsExpr Id))
+addTickMatch :: Bool -> Bool -> Match GhcTc (LHsExpr GhcTc)
+ -> TM (Match GhcTc (LHsExpr GhcTc))
addTickMatch isOneOfMany isLambda (Match mf pats opSig gRHSs) =
bindLocals (collectPatsBinders pats) $ do
gRHSs' <- addTickGRHSs isOneOfMany isLambda gRHSs
return $ Match mf pats opSig gRHSs'
-addTickGRHSs :: Bool -> Bool -> GRHSs Id (LHsExpr Id) -> TM (GRHSs Id (LHsExpr Id))
+addTickGRHSs :: Bool -> Bool -> GRHSs GhcTc (LHsExpr GhcTc)
+ -> TM (GRHSs GhcTc (LHsExpr GhcTc))
addTickGRHSs isOneOfMany isLambda (GRHSs guarded (L l local_binds)) = do
bindLocals binders $ do
local_binds' <- addTickHsLocalBinds local_binds
@@ -694,13 +697,14 @@ addTickGRHSs isOneOfMany isLambda (GRHSs guarded (L l local_binds)) = do
where
binders = collectLocalBinders local_binds
-addTickGRHS :: Bool -> Bool -> GRHS Id (LHsExpr Id) -> TM (GRHS Id (LHsExpr Id))
+addTickGRHS :: Bool -> Bool -> GRHS GhcTc (LHsExpr GhcTc)
+ -> TM (GRHS GhcTc (LHsExpr GhcTc))
addTickGRHS isOneOfMany isLambda (GRHS stmts expr) = do
(stmts',expr') <- addTickLStmts' (Just $ BinBox $ GuardBinBox) stmts
(addTickGRHSBody isOneOfMany isLambda expr)
return $ GRHS stmts' expr'
-addTickGRHSBody :: Bool -> Bool -> LHsExpr Id -> TM (LHsExpr Id)
+addTickGRHSBody :: Bool -> Bool -> LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTickGRHSBody isOneOfMany isLambda expr@(L pos e0) = do
d <- getDensity
case d of
@@ -712,20 +716,22 @@ addTickGRHSBody isOneOfMany isLambda expr@(L pos e0) = do
_otherwise ->
addTickLHsExprRHS expr
-addTickLStmts :: (Maybe (Bool -> BoxLabel)) -> [ExprLStmt Id] -> TM [ExprLStmt Id]
+addTickLStmts :: (Maybe (Bool -> BoxLabel)) -> [ExprLStmt GhcTc]
+ -> TM [ExprLStmt GhcTc]
addTickLStmts isGuard stmts = do
(stmts, _) <- addTickLStmts' isGuard stmts (return ())
return stmts
-addTickLStmts' :: (Maybe (Bool -> BoxLabel)) -> [ExprLStmt Id] -> TM a
- -> TM ([ExprLStmt Id], a)
+addTickLStmts' :: (Maybe (Bool -> BoxLabel)) -> [ExprLStmt GhcTc] -> TM a
+ -> TM ([ExprLStmt GhcTc], a)
addTickLStmts' isGuard lstmts res
= bindLocals (collectLStmtsBinders lstmts) $
do { lstmts' <- mapM (liftL (addTickStmt isGuard)) lstmts
; a <- res
; return (lstmts', a) }
-addTickStmt :: (Maybe (Bool -> BoxLabel)) -> Stmt Id (LHsExpr Id) -> TM (Stmt Id (LHsExpr Id))
+addTickStmt :: (Maybe (Bool -> BoxLabel)) -> Stmt GhcTc (LHsExpr GhcTc)
+ -> TM (Stmt GhcTc (LHsExpr GhcTc))
addTickStmt _isGuard (LastStmt e noret ret) = do
liftM3 LastStmt
(addTickLHsExpr e)
@@ -778,13 +784,13 @@ addTickStmt isGuard stmt@(RecStmt {})
; return (stmt { recS_stmts = stmts', recS_ret_fn = ret'
, recS_mfix_fn = mfix', recS_bind_fn = bind' }) }
-addTick :: Maybe (Bool -> BoxLabel) -> LHsExpr Id -> TM (LHsExpr Id)
+addTick :: Maybe (Bool -> BoxLabel) -> LHsExpr GhcTc -> TM (LHsExpr GhcTc)
addTick isGuard e | Just fn <- isGuard = addBinTickLHsExpr fn e
| otherwise = addTickLHsExprRHS e
addTickApplicativeArg
- :: Maybe (Bool -> BoxLabel) -> (SyntaxExpr Id, ApplicativeArg Id Id)
- -> TM (SyntaxExpr Id, ApplicativeArg Id Id)
+ :: Maybe (Bool -> BoxLabel) -> (SyntaxExpr GhcTc, ApplicativeArg GhcTc GhcTc)
+ -> TM (SyntaxExpr GhcTc, ApplicativeArg GhcTc GhcTc)
addTickApplicativeArg isGuard (op, arg) =
liftM2 (,) (addTickSyntaxExpr hpcSrcSpan op) (addTickArg arg)
where
@@ -796,15 +802,15 @@ addTickApplicativeArg isGuard (op, arg) =
<*> (unLoc <$> addTickLHsExpr (L hpcSrcSpan ret))
<*> addTickLPat pat
-addTickStmtAndBinders :: Maybe (Bool -> BoxLabel) -> ParStmtBlock Id Id
- -> TM (ParStmtBlock Id Id)
+addTickStmtAndBinders :: Maybe (Bool -> BoxLabel) -> ParStmtBlock GhcTc GhcTc
+ -> TM (ParStmtBlock GhcTc GhcTc)
addTickStmtAndBinders isGuard (ParStmtBlock stmts ids returnExpr) =
liftM3 ParStmtBlock
(addTickLStmts isGuard stmts)
(return ids)
(addTickSyntaxExpr hpcSrcSpan returnExpr)
-addTickHsLocalBinds :: HsLocalBinds Id -> TM (HsLocalBinds Id)
+addTickHsLocalBinds :: HsLocalBinds GhcTc -> TM (HsLocalBinds GhcTc)
addTickHsLocalBinds (HsValBinds binds) =
liftM HsValBinds
(addTickHsValBinds binds)
@@ -813,7 +819,7 @@ addTickHsLocalBinds (HsIPBinds binds) =
(addTickHsIPBinds binds)
addTickHsLocalBinds (EmptyLocalBinds) = return EmptyLocalBinds
-addTickHsValBinds :: HsValBindsLR Id a -> TM (HsValBindsLR Id b)
+addTickHsValBinds :: HsValBindsLR GhcTc a -> TM (HsValBindsLR GhcTc b)
addTickHsValBinds (ValBindsOut binds sigs) =
liftM2 ValBindsOut
(mapM (\ (rec,binds') ->
@@ -824,28 +830,28 @@ addTickHsValBinds (ValBindsOut binds sigs) =
(return sigs)
addTickHsValBinds _ = panic "addTickHsValBinds"
-addTickHsIPBinds :: HsIPBinds Id -> TM (HsIPBinds Id)
+addTickHsIPBinds :: HsIPBinds GhcTc -> TM (HsIPBinds GhcTc)
addTickHsIPBinds (IPBinds ipbinds dictbinds) =
liftM2 IPBinds
(mapM (liftL (addTickIPBind)) ipbinds)
(return dictbinds)
-addTickIPBind :: IPBind Id -> TM (IPBind Id)
+addTickIPBind :: IPBind GhcTc -> TM (IPBind GhcTc)
addTickIPBind (IPBind nm e) =
liftM2 IPBind
(return nm)
(addTickLHsExpr e)
-- There is no location here, so we might need to use a context location??
-addTickSyntaxExpr :: SrcSpan -> SyntaxExpr Id -> TM (SyntaxExpr Id)
+addTickSyntaxExpr :: SrcSpan -> SyntaxExpr GhcTc -> TM (SyntaxExpr GhcTc)
addTickSyntaxExpr pos syn@(SyntaxExpr { syn_expr = x }) = do
L _ x' <- addTickLHsExpr (L pos x)
return $ syn { syn_expr = x' }
-- we do not walk into patterns.
-addTickLPat :: LPat Id -> TM (LPat Id)
+addTickLPat :: LPat GhcTc -> TM (LPat GhcTc)
addTickLPat pat = return pat
-addTickHsCmdTop :: HsCmdTop Id -> TM (HsCmdTop Id)
+addTickHsCmdTop :: HsCmdTop GhcTc -> TM (HsCmdTop GhcTc)
addTickHsCmdTop (HsCmdTop cmd tys ty syntaxtable) =
liftM4 HsCmdTop
(addTickLHsCmd cmd)
@@ -853,12 +859,12 @@ addTickHsCmdTop (HsCmdTop cmd tys ty syntaxtable) =
(return ty)
(return syntaxtable)
-addTickLHsCmd :: LHsCmd Id -> TM (LHsCmd Id)
+addTickLHsCmd :: LHsCmd GhcTc -> TM (LHsCmd GhcTc)
addTickLHsCmd (L pos c0) = do
c1 <- addTickHsCmd c0
return $ L pos c1
-addTickHsCmd :: HsCmd Id -> TM (HsCmd Id)
+addTickHsCmd :: HsCmd GhcTc -> TM (HsCmd GhcTc)
addTickHsCmd (HsCmdLam matchgroup) =
liftM HsCmdLam (addTickCmdMatchGroup matchgroup)
addTickHsCmd (HsCmdApp c e) =
@@ -910,18 +916,19 @@ addTickHsCmd (HsCmdWrap w cmd)
-- Others should never happen in a command context.
--addTickHsCmd e = pprPanic "addTickHsCmd" (ppr e)
-addTickCmdMatchGroup :: MatchGroup Id (LHsCmd Id) -> TM (MatchGroup Id (LHsCmd Id))
+addTickCmdMatchGroup :: MatchGroup GhcTc (LHsCmd GhcTc)
+ -> TM (MatchGroup GhcTc (LHsCmd GhcTc))
addTickCmdMatchGroup mg@(MG { mg_alts = L l matches }) = do
matches' <- mapM (liftL addTickCmdMatch) matches
return $ mg { mg_alts = L l matches' }
-addTickCmdMatch :: Match Id (LHsCmd Id) -> TM (Match Id (LHsCmd Id))
+addTickCmdMatch :: Match GhcTc (LHsCmd GhcTc) -> TM (Match GhcTc (LHsCmd GhcTc))
addTickCmdMatch (Match mf pats opSig gRHSs) =
bindLocals (collectPatsBinders pats) $ do
gRHSs' <- addTickCmdGRHSs gRHSs
return $ Match mf pats opSig gRHSs'
-addTickCmdGRHSs :: GRHSs Id (LHsCmd Id) -> TM (GRHSs Id (LHsCmd Id))
+addTickCmdGRHSs :: GRHSs GhcTc (LHsCmd GhcTc) -> TM (GRHSs GhcTc (LHsCmd GhcTc))
addTickCmdGRHSs (GRHSs guarded (L l local_binds)) = do
bindLocals binders $ do
local_binds' <- addTickHsLocalBinds local_binds
@@ -930,7 +937,7 @@ addTickCmdGRHSs (GRHSs guarded (L l local_binds)) = do
where
binders = collectLocalBinders local_binds
-addTickCmdGRHS :: GRHS Id (LHsCmd Id) -> TM (GRHS Id (LHsCmd Id))
+addTickCmdGRHS :: GRHS GhcTc (LHsCmd GhcTc) -> TM (GRHS GhcTc (LHsCmd GhcTc))
-- The *guards* are *not* Cmds, although the body is
-- C.f. addTickGRHS for the BinBox stuff
addTickCmdGRHS (GRHS stmts cmd)
@@ -938,12 +945,14 @@ addTickCmdGRHS (GRHS stmts cmd)
stmts (addTickLHsCmd cmd)
; return $ GRHS stmts' expr' }
-addTickLCmdStmts :: [LStmt Id (LHsCmd Id)] -> TM [LStmt Id (LHsCmd Id)]
+addTickLCmdStmts :: [LStmt GhcTc (LHsCmd GhcTc)]
+ -> TM [LStmt GhcTc (LHsCmd GhcTc)]
addTickLCmdStmts stmts = do
(stmts, _) <- addTickLCmdStmts' stmts (return ())
return stmts
-addTickLCmdStmts' :: [LStmt Id (LHsCmd Id)] -> TM a -> TM ([LStmt Id (LHsCmd Id)], a)
+addTickLCmdStmts' :: [LStmt GhcTc (LHsCmd GhcTc)] -> TM a
+ -> TM ([LStmt GhcTc (LHsCmd GhcTc)], a)
addTickLCmdStmts' lstmts res
= bindLocals binders $ do
lstmts' <- mapM (liftL addTickCmdStmt) lstmts
@@ -952,7 +961,7 @@ addTickLCmdStmts' lstmts res
where
binders = collectLStmtsBinders lstmts
-addTickCmdStmt :: Stmt Id (LHsCmd Id) -> TM (Stmt Id (LHsCmd Id))
+addTickCmdStmt :: Stmt GhcTc (LHsCmd GhcTc) -> TM (Stmt GhcTc (LHsCmd GhcTc))
addTickCmdStmt (BindStmt pat c bind fail ty) = do
liftM5 BindStmt
(addTickLPat pat)
@@ -987,18 +996,19 @@ addTickCmdStmt ApplicativeStmt{} =
-- Others should never happen in a command context.
addTickCmdStmt stmt = pprPanic "addTickHsCmd" (ppr stmt)
-addTickHsRecordBinds :: HsRecordBinds Id -> TM (HsRecordBinds Id)
+addTickHsRecordBinds :: HsRecordBinds GhcTc -> TM (HsRecordBinds GhcTc)
addTickHsRecordBinds (HsRecFields fields dd)
= do { fields' <- mapM addTickHsRecField fields
; return (HsRecFields fields' dd) }
-addTickHsRecField :: LHsRecField' id (LHsExpr Id) -> TM (LHsRecField' id (LHsExpr Id))
+addTickHsRecField :: LHsRecField' id (LHsExpr GhcTc)
+ -> TM (LHsRecField' id (LHsExpr GhcTc))
addTickHsRecField (L l (HsRecField id expr pun))
= do { expr' <- addTickLHsExpr expr
; return (L l (HsRecField id expr' pun)) }
-addTickArithSeqInfo :: ArithSeqInfo Id -> TM (ArithSeqInfo Id)
+addTickArithSeqInfo :: ArithSeqInfo GhcTc -> TM (ArithSeqInfo GhcTc)
addTickArithSeqInfo (From e1) =
liftM From
(addTickLHsExpr e1)
@@ -1174,8 +1184,8 @@ isBlackListed pos = TM $ \ env st ->
-- the tick application inherits the source position of its
-- expression argument to support nested box allocations
-allocTickBox :: BoxLabel -> Bool -> Bool -> SrcSpan -> TM (HsExpr Id)
- -> TM (LHsExpr Id)
+allocTickBox :: BoxLabel -> Bool -> Bool -> SrcSpan -> TM (HsExpr GhcTc)
+ -> TM (LHsExpr GhcTc)
allocTickBox boxLabel countEntries topOnly pos m =
ifGoodTickSrcSpan pos (do
(fvs, e) <- getFreeVars m
@@ -1246,8 +1256,8 @@ mkTickish boxLabel countEntries topOnly pos fvs decl_path = do
_otherwise -> panic "mkTickish: bad source span!"
-allocBinTickBox :: (Bool -> BoxLabel) -> SrcSpan -> TM (HsExpr Id)
- -> TM (LHsExpr Id)
+allocBinTickBox :: (Bool -> BoxLabel) -> SrcSpan -> TM (HsExpr GhcTc)
+ -> TM (LHsExpr GhcTc)
allocBinTickBox boxLabel pos m = do
env <- getEnv
case tickishType env of
@@ -1257,8 +1267,8 @@ allocBinTickBox boxLabel pos m = do
(return e)
_other -> allocTickBox (ExpBox False) False False pos m
-mkBinTickBoxHpc :: (Bool -> BoxLabel) -> SrcSpan -> LHsExpr Id
- -> TM (LHsExpr Id)
+mkBinTickBoxHpc :: (Bool -> BoxLabel) -> SrcSpan -> LHsExpr GhcTc
+ -> TM (LHsExpr GhcTc)
mkBinTickBoxHpc boxLabel pos e =
TM $ \ env st ->
let meT = (pos,declPath env, [],boxLabel True)
@@ -1291,7 +1301,7 @@ mkHpcPos _ = panic "bad source span; expected such spans to be filtered out"
hpcSrcSpan :: SrcSpan
hpcSrcSpan = mkGeneralSrcSpan (fsLit "Haskell Program Coverage internals")
-matchesOneOfMany :: [LMatch Id body] -> Bool
+matchesOneOfMany :: [LMatch GhcTc body] -> Bool
matchesOneOfMany lmatches = sum (map matchCount lmatches) > 1
where
matchCount (L _ (Match _ _pats _ty (GRHSs grhss _binds))) = length grhss
diff --git a/compiler/deSugar/Desugar.hs b/compiler/deSugar/Desugar.hs
index 0d8965a118..3d8a28f7b0 100644
--- a/compiler/deSugar/Desugar.hs
+++ b/compiler/deSugar/Desugar.hs
@@ -7,6 +7,7 @@ The Desugarer: turning HsSyn into Core.
-}
{-# LANGUAGE CPP #-}
+{-# LANGUAGE TypeFamilies #-}
module Desugar (
-- * Desugaring operations
@@ -250,7 +251,7 @@ So we pull out the type/coercion variables (which are in dependency order),
and Rec the rest.
-}
-deSugarExpr :: HscEnv -> LHsExpr Id -> IO (Messages, Maybe CoreExpr)
+deSugarExpr :: HscEnv -> LHsExpr GhcTc -> IO (Messages, Maybe CoreExpr)
deSugarExpr hsc_env tc_expr = do {
let dflags = hsc_dflags hsc_env
@@ -362,7 +363,7 @@ Reason
************************************************************************
-}
-dsRule :: LRuleDecl Id -> DsM (Maybe CoreRule)
+dsRule :: LRuleDecl GhcTc -> DsM (Maybe CoreRule)
dsRule (L loc (HsRule name rule_act vars lhs _tv_lhs rhs _fv_rhs))
= putSrcSpanDs loc $
do { let bndrs' = [var | L _ (RuleBndr (L _ var)) <- vars]
@@ -541,7 +542,7 @@ subsequent transformations could fire.
************************************************************************
-}
-dsVect :: LVectDecl Id -> DsM CoreVect
+dsVect :: LVectDecl GhcTc -> DsM CoreVect
dsVect (L loc (HsVect _ (L _ v) rhs))
= putSrcSpanDs loc $
do { rhs' <- dsLExpr rhs
diff --git a/compiler/deSugar/DsArrows.hs b/compiler/deSugar/DsArrows.hs
index 4fe43eb1c0..fb16d53e78 100644
--- a/compiler/deSugar/DsArrows.hs
+++ b/compiler/deSugar/DsArrows.hs
@@ -7,6 +7,7 @@ Desugaring arrow commands
-}
{-# LANGUAGE CPP #-}
+{-# LANGUAGE TypeFamilies #-}
module DsArrows ( dsProcExpr ) where
@@ -37,7 +38,6 @@ import MkCore
import DsBinds (dsHsWrapper)
import Name
-import Var
import Id
import ConLike
import TysWiredIn
@@ -57,7 +57,7 @@ data DsCmdEnv = DsCmdEnv {
arr_id, compose_id, first_id, app_id, choice_id, loop_id :: CoreExpr
}
-mkCmdEnv :: CmdSyntaxTable Id -> DsM ([CoreBind], DsCmdEnv)
+mkCmdEnv :: CmdSyntaxTable GhcTc -> DsM ([CoreBind], DsCmdEnv)
-- See Note [CmdSyntaxTable] in HsExpr
mkCmdEnv tc_meths
= do { (meth_binds, prs) <- mapAndUnzipM mk_bind tc_meths
@@ -295,7 +295,7 @@ matchVarStack (param_id:param_ids) stack_id body = do
pair_id <- newSysLocalDs (mkCorePairTy (idType param_id) (idType tail_id))
return (pair_id, coreCasePair pair_id param_id tail_id tail_code)
-mkHsEnvStackExpr :: [Id] -> Id -> LHsExpr Id
+mkHsEnvStackExpr :: [Id] -> Id -> LHsExpr GhcTc
mkHsEnvStackExpr env_ids stack_id
= mkLHsTupleExpr [mkLHsVarTuple env_ids, nlHsVar stack_id]
@@ -308,8 +308,8 @@ mkHsEnvStackExpr env_ids stack_id
-- where (xs) is the tuple of variables bound by p
dsProcExpr
- :: LPat Id
- -> LHsCmdTop Id
+ :: LPat GhcTc
+ -> LHsCmdTop GhcTc
-> DsM CoreExpr
dsProcExpr pat (L _ (HsCmdTop cmd _unitTy cmd_ty ids)) = do
(meth_binds, meth_ids) <- mkCmdEnv ids
@@ -337,7 +337,7 @@ to an expression e such that
D |- e :: a (xs, stk) t
-}
-dsLCmd :: DsCmdEnv -> IdSet -> Type -> Type -> LHsCmd Id -> [Id]
+dsLCmd :: DsCmdEnv -> IdSet -> Type -> Type -> LHsCmd GhcTc -> [Id]
-> DsM (CoreExpr, DIdSet)
dsLCmd ids local_vars stk_ty res_ty cmd env_ids
= dsCmd ids local_vars stk_ty res_ty (unLoc cmd) env_ids
@@ -346,8 +346,8 @@ dsCmd :: DsCmdEnv -- arrow combinators
-> IdSet -- set of local vars available to this command
-> Type -- type of the stack (right-nested tuple)
-> Type -- return type of the command
- -> HsCmd Id -- command to desugar
- -> [Id] -- list of vars in the input to this command
+ -> HsCmd GhcTc -- command to desugar
+ -> [Id] -- list of vars in the input to this command
-- This is typically fed back,
-- so don't pull on it too early
-> DsM (CoreExpr, -- desugared expression
@@ -676,8 +676,8 @@ dsCmd _ _ _ _ _ c = pprPanic "dsCmd" (ppr c)
dsTrimCmdArg
:: IdSet -- set of local vars available to this command
- -> [Id] -- list of vars in the input to this command
- -> LHsCmdTop Id -- command argument to desugar
+ -> [Id] -- list of vars in the input to this command
+ -> LHsCmdTop GhcTc -- command argument to desugar
-> DsM (CoreExpr, -- desugared expression
DIdSet) -- subset of local vars that occur free
dsTrimCmdArg local_vars env_ids (L _ (HsCmdTop cmd stack_ty cmd_ty ids)) = do
@@ -700,7 +700,7 @@ dsfixCmd
-> IdSet -- set of local vars available to this command
-> Type -- type of the stack (right-nested tuple)
-> Type -- return type of the command
- -> LHsCmd Id -- command to desugar
+ -> LHsCmd GhcTc -- command to desugar
-> DsM (CoreExpr, -- desugared expression
DIdSet, -- subset of local vars that occur free
[Id]) -- the same local vars as a list, fed back
@@ -733,7 +733,7 @@ Translation of command judgements of the form
dsCmdDo :: DsCmdEnv -- arrow combinators
-> IdSet -- set of local vars available to this statement
-> Type -- return type of the statement
- -> [CmdLStmt Id] -- statements to desugar
+ -> [CmdLStmt GhcTc] -- statements to desugar
-> [Id] -- list of vars in the input to this statement
-- This is typically fed back,
-- so don't pull on it too early
@@ -782,7 +782,7 @@ as an arrow from one tuple type to another. A statement sequence is
translated to a composition of such arrows.
-}
-dsCmdLStmt :: DsCmdEnv -> IdSet -> [Id] -> CmdLStmt Id -> [Id]
+dsCmdLStmt :: DsCmdEnv -> IdSet -> [Id] -> CmdLStmt GhcTc -> [Id]
-> DsM (CoreExpr, DIdSet)
dsCmdLStmt ids local_vars out_ids cmd env_ids
= dsCmdStmt ids local_vars out_ids (unLoc cmd) env_ids
@@ -791,7 +791,7 @@ dsCmdStmt
:: DsCmdEnv -- arrow combinators
-> IdSet -- set of local vars available to this statement
-> [Id] -- list of vars in the output of this statement
- -> CmdStmt Id -- statement to desugar
+ -> CmdStmt GhcTc -- statement to desugar
-> [Id] -- list of vars in the input to this statement
-- This is typically fed back,
-- so don't pull on it too early
@@ -973,11 +973,11 @@ dsCmdStmt _ _ _ _ s = pprPanic "dsCmdStmt" (ppr s)
dsRecCmd
:: DsCmdEnv -- arrow combinators
-> IdSet -- set of local vars available to this statement
- -> [CmdLStmt Id] -- list of statements inside the RecCmd
+ -> [CmdLStmt GhcTc] -- list of statements inside the RecCmd
-> [Id] -- list of vars defined here and used later
- -> [HsExpr Id] -- expressions corresponding to later_ids
+ -> [HsExpr GhcTc] -- expressions corresponding to later_ids
-> [Id] -- list of vars fed back through the loop
- -> [HsExpr Id] -- expressions corresponding to rec_ids
+ -> [HsExpr GhcTc] -- expressions corresponding to rec_ids
-> DsM (CoreExpr, -- desugared statement
DIdSet, -- subset of local vars that occur free
[Id]) -- same local vars as a list
@@ -1051,7 +1051,7 @@ dsfixCmdStmts
:: DsCmdEnv -- arrow combinators
-> IdSet -- set of local vars available to this statement
-> [Id] -- output vars of these statements
- -> [CmdLStmt Id] -- statements to desugar
+ -> [CmdLStmt GhcTc] -- statements to desugar
-> DsM (CoreExpr, -- desugared expression
DIdSet, -- subset of local vars that occur free
[Id]) -- same local vars as a list
@@ -1065,7 +1065,7 @@ dsCmdStmts
:: DsCmdEnv -- arrow combinators
-> IdSet -- set of local vars available to this statement
-> [Id] -- output vars of these statements
- -> [CmdLStmt Id] -- statements to desugar
+ -> [CmdLStmt GhcTc] -- statements to desugar
-> [Id] -- list of vars in the input to these statements
-> DsM (CoreExpr, -- desugared expression
DIdSet) -- subset of local vars that occur free
@@ -1092,7 +1092,7 @@ dsCmdStmts _ _ _ [] _ = panic "dsCmdStmts []"
matchSimplys :: [CoreExpr] -- Scrutinees
-> HsMatchContext Name -- Match kind
- -> [LPat Id] -- Patterns they should match
+ -> [LPat GhcTc] -- Patterns they should match
-> CoreExpr -- Return this if they all match
-> CoreExpr -- Return this if they don't
-> DsM CoreExpr
@@ -1104,7 +1104,8 @@ matchSimplys _ _ _ _ _ = panic "matchSimplys"
-- List of leaf expressions, with set of variables bound in each
-leavesMatch :: LMatch Id (Located (body Id)) -> [(Located (body Id), IdSet)]
+leavesMatch :: LMatch GhcTc (Located (body GhcTc))
+ -> [(Located (body GhcTc), IdSet)]
leavesMatch (L _ (Match _ pats _ (GRHSs grhss (L _ binds))))
= let
defined_vars = mkVarSet (collectPatsBinders pats)
@@ -1120,10 +1121,10 @@ leavesMatch (L _ (Match _ pats _ (GRHSs grhss (L _ binds))))
replaceLeavesMatch
:: Type -- new result type
- -> [Located (body' Id)] -- replacement leaf expressions of that type
- -> LMatch Id (Located (body Id)) -- the matches of a case command
- -> ([Located (body' Id)], -- remaining leaf expressions
- LMatch Id (Located (body' Id))) -- updated match
+ -> [Located (body' GhcTc)] -- replacement leaf expressions of that type
+ -> LMatch GhcTc (Located (body GhcTc)) -- the matches of a case command
+ -> ([Located (body' GhcTc)], -- remaining leaf expressions
+ LMatch GhcTc (Located (body' GhcTc))) -- updated match
replaceLeavesMatch _res_ty leaves (L loc (Match mf pat mt (GRHSs grhss binds)))
= let
(leaves', grhss') = mapAccumL replaceLeavesGRHS leaves grhss
@@ -1131,10 +1132,10 @@ replaceLeavesMatch _res_ty leaves (L loc (Match mf pat mt (GRHSs grhss binds)))
(leaves', L loc (Match mf pat mt (GRHSs grhss' binds)))
replaceLeavesGRHS
- :: [Located (body' Id)] -- replacement leaf expressions of that type
- -> LGRHS Id (Located (body Id)) -- rhss of a case command
- -> ([Located (body' Id)], -- remaining leaf expressions
- LGRHS Id (Located (body' Id))) -- updated GRHS
+ :: [Located (body' GhcTc)] -- replacement leaf expressions of that type
+ -> LGRHS GhcTc (Located (body GhcTc)) -- rhss of a case command
+ -> ([Located (body' GhcTc)], -- remaining leaf expressions
+ LGRHS GhcTc (Located (body' GhcTc))) -- updated GRHS
replaceLeavesGRHS (leaf:leaves) (L loc (GRHS stmts _))
= (leaves, L loc (GRHS stmts leaf))
replaceLeavesGRHS [] _ = panic "replaceLeavesGRHS []"
@@ -1172,14 +1173,14 @@ See comments in HsUtils for why the other version does not include
these bindings.
-}
-collectPatBinders :: LPat Id -> [Id]
+collectPatBinders :: LPat GhcTc -> [Id]
collectPatBinders pat = collectl pat []
-collectPatsBinders :: [LPat Id] -> [Id]
+collectPatsBinders :: [LPat GhcTc] -> [Id]
collectPatsBinders pats = foldr collectl [] pats
---------------------
-collectl :: LPat Id -> [Id] -> [Id]
+collectl :: LPat GhcTc -> [Id] -> [Id]
-- See Note [Dictionary binders in ConPatOut]
collectl (L _ pat) bndrs
= go pat
@@ -1219,12 +1220,12 @@ add_ev_bndr (EvBind { eb_lhs = b }) bs | isId b = b:bs
| otherwise = bs
-- A worry: what about coercion variable binders??
-collectLStmtsBinders :: [LStmt Id body] -> [Id]
+collectLStmtsBinders :: [LStmt GhcTc body] -> [Id]
collectLStmtsBinders = concatMap collectLStmtBinders
-collectLStmtBinders :: LStmt Id body -> [Id]
+collectLStmtBinders :: LStmt GhcTc body -> [Id]
collectLStmtBinders = collectStmtBinders . unLoc
-collectStmtBinders :: Stmt Id body -> [Id]
+collectStmtBinders :: Stmt GhcTc body -> [Id]
collectStmtBinders (RecStmt { recS_later_ids = later_ids }) = later_ids
collectStmtBinders stmt = HsUtils.collectStmtBinders stmt
diff --git a/compiler/deSugar/DsBinds.hs b/compiler/deSugar/DsBinds.hs
index 26aebe9363..2a0abca5de 100644
--- a/compiler/deSugar/DsBinds.hs
+++ b/compiler/deSugar/DsBinds.hs
@@ -11,6 +11,7 @@ lower levels it is preserved with @let@/@letrec@s).
-}
{-# LANGUAGE CPP #-}
+{-# LANGUAGE TypeFamilies #-}
module DsBinds ( dsTopLHsBinds, dsLHsBinds, decomposeRuleLhs, dsSpec,
dsHsWrapper, dsTcEvBinds, dsTcEvBinds_s, dsEvBinds, dsMkUserRule
@@ -73,7 +74,7 @@ import Control.Monad
-- | Desugar top level binds, strict binds are treated like normal
-- binds since there is no good time to force before first usage.
-dsTopLHsBinds :: LHsBinds Id -> DsM (OrdList (Id,CoreExpr))
+dsTopLHsBinds :: LHsBinds GhcTc -> DsM (OrdList (Id,CoreExpr))
dsTopLHsBinds binds
-- see Note [Strict binds checks]
| not (isEmptyBag unlifted_binds) || not (isEmptyBag bang_binds)
@@ -102,7 +103,7 @@ dsTopLHsBinds binds
-- | Desugar all other kind of bindings, Ids of strict binds are returned to
-- later be forced in the binding group body, see Note [Desugar Strict binds]
-dsLHsBinds :: LHsBinds Id -> DsM ([Id], [(Id,CoreExpr)])
+dsLHsBinds :: LHsBinds GhcTc -> DsM ([Id], [(Id,CoreExpr)])
dsLHsBinds binds
= do { MASSERT( allBag (not . isUnliftedHsBind . unLoc) binds )
; ds_bs <- mapBagM dsLHsBind binds
@@ -110,14 +111,14 @@ dsLHsBinds binds
id ([], []) ds_bs) }
------------------------
-dsLHsBind :: LHsBind Id
+dsLHsBind :: LHsBind GhcTc
-> DsM ([Id], [(Id,CoreExpr)])
dsLHsBind (L loc bind) = do dflags <- getDynFlags
putSrcSpanDs loc $ dsHsBind dflags bind
-- | Desugar a single binding (or group of recursive binds).
dsHsBind :: DynFlags
- -> HsBind Id
+ -> HsBind GhcTc
-> DsM ([Id], [(Id,CoreExpr)])
-- ^ The Ids of strict binds, to be forced in the body of the
-- binding group see Note [Desugar Strict binds] and all
@@ -275,7 +276,7 @@ dsHsBind dflags
,(poly_tup_id, poly_tup_rhs) :
concat export_binds_s) }
where
- inline_env :: IdEnv Id -- Maps a monomorphic local Id to one with
+ inline_env :: IdEnv Id -- Maps a monomorphic local Id to one with
-- the inline pragma from the source
-- The type checker put the inline pragma
-- on the *global* Id, so we need to transfer it
@@ -302,7 +303,7 @@ dsHsBind dflags
[] lcls
-- find exports or make up new exports for force variables
- get_exports :: [Id] -> DsM ([Id], [ABExport Id])
+ get_exports :: [Id] -> DsM ([Id], [ABExport GhcTc])
get_exports lcls =
foldM (\(glbls, exports) lcl ->
case lookupVarEnv global_env lcl of
@@ -373,7 +374,8 @@ dsHsBind _ (PatSynBind{}) = panic "dsHsBind: PatSynBind"
-- the unfolding in the interface file is made in `TidyPgm.addExternal`
-- using this information.
------------------------
-makeCorePair :: DynFlags -> Id -> Bool -> Arity -> CoreExpr -> (Id, CoreExpr)
+makeCorePair :: DynFlags -> Id -> Bool -> Arity -> CoreExpr
+ -> (Id, CoreExpr)
makeCorePair dflags gbl_id is_default_method dict_arity rhs
| is_default_method -- Default methods are *always* inlined
= (gbl_id `setIdUnfolding` mkCompulsoryUnfolding rhs, rhs)
diff --git a/compiler/deSugar/DsExpr.hs b/compiler/deSugar/DsExpr.hs
index cfd9996f1a..c3d9489476 100644
--- a/compiler/deSugar/DsExpr.hs
+++ b/compiler/deSugar/DsExpr.hs
@@ -7,6 +7,7 @@ Desugaring exporessions.
-}
{-# LANGUAGE CPP, MultiWayIf #-}
+{-# LANGUAGE TypeFamilies #-}
module DsExpr ( dsExpr, dsLExpr, dsLExprNoLP, dsLocalBinds
, dsValBinds, dsLit, dsSyntaxExpr ) where
@@ -66,7 +67,7 @@ import Control.Monad
************************************************************************
-}
-dsLocalBinds :: LHsLocalBinds Id -> CoreExpr -> DsM CoreExpr
+dsLocalBinds :: LHsLocalBinds GhcTc -> CoreExpr -> DsM CoreExpr
dsLocalBinds (L _ EmptyLocalBinds) body = return body
dsLocalBinds (L loc (HsValBinds binds)) body = putSrcSpanDs loc $
dsValBinds binds body
@@ -74,12 +75,12 @@ dsLocalBinds (L _ (HsIPBinds binds)) body = dsIPBinds binds body
-------------------------
-- caller sets location
-dsValBinds :: HsValBinds Id -> CoreExpr -> DsM CoreExpr
+dsValBinds :: HsValBinds GhcTc -> CoreExpr -> DsM CoreExpr
dsValBinds (ValBindsOut binds _) body = foldrM ds_val_bind body binds
dsValBinds (ValBindsIn {}) _ = panic "dsValBinds ValBindsIn"
-------------------------
-dsIPBinds :: HsIPBinds Id -> CoreExpr -> DsM CoreExpr
+dsIPBinds :: HsIPBinds GhcTc -> CoreExpr -> DsM CoreExpr
dsIPBinds (IPBinds ip_binds ev_binds) body
= do { ds_binds <- dsTcEvBinds ev_binds
; let inner = mkCoreLets ds_binds body
@@ -93,7 +94,7 @@ dsIPBinds (IPBinds ip_binds ev_binds) body
-------------------------
-- caller sets location
-ds_val_bind :: (RecFlag, LHsBinds Id) -> CoreExpr -> DsM CoreExpr
+ds_val_bind :: (RecFlag, LHsBinds GhcTc) -> CoreExpr -> DsM CoreExpr
-- Special case for bindings which bind unlifted variables
-- We need to do a case right away, rather than building
-- a tuple and doing selections.
@@ -173,7 +174,7 @@ ds_val_bind (is_rec, binds) body
-- only have to deal with lifted ones now; so Rec is ok
------------------
-dsUnliftedBind :: HsBind Id -> CoreExpr -> DsM CoreExpr
+dsUnliftedBind :: HsBind GhcTc -> CoreExpr -> DsM CoreExpr
dsUnliftedBind (AbsBinds { abs_tvs = [], abs_ev_vars = []
, abs_exports = exports
, abs_ev_binds = ev_binds
@@ -228,7 +229,7 @@ dsUnliftedBind bind body = pprPanic "dsLet: unlifted" (ppr bind $$ ppr body)
************************************************************************
-}
-dsLExpr :: LHsExpr Id -> DsM CoreExpr
+dsLExpr :: LHsExpr GhcTc -> DsM CoreExpr
dsLExpr (L loc e)
= putSrcSpanDs loc $
@@ -244,19 +245,19 @@ dsLExpr (L loc e)
-- be an argument to some other function.
-- See Note [Levity polymorphism checking] in DsMonad
-- See Note [Levity polymorphism invariants] in CoreSyn
-dsLExprNoLP :: LHsExpr Id -> DsM CoreExpr
+dsLExprNoLP :: LHsExpr GhcTc -> DsM CoreExpr
dsLExprNoLP (L loc e)
= putSrcSpanDs loc $
do { e' <- dsExpr e
; dsNoLevPolyExpr e' (text "In the type of expression:" <+> ppr e)
; return e' }
-dsExpr :: HsExpr Id -> DsM CoreExpr
+dsExpr :: HsExpr GhcTc -> DsM CoreExpr
dsExpr = ds_expr False
ds_expr :: Bool -- are we directly inside an HsWrap?
-- See Wrinkle in Note [Detecting forced eta expansion]
- -> HsExpr Id -> DsM CoreExpr
+ -> HsExpr GhcTc -> DsM CoreExpr
ds_expr _ (HsPar e) = dsLExpr e
ds_expr _ (ExprWithTySigOut e _) = dsLExpr e
ds_expr w (HsVar (L _ var)) = dsHsVar w var
@@ -264,7 +265,7 @@ ds_expr _ (HsUnboundVar {}) = panic "dsExpr: HsUnboundVar" -- Typechecker e
ds_expr w (HsConLikeOut con) = dsConLike w con
ds_expr _ (HsIPVar _) = panic "dsExpr: HsIPVar"
ds_expr _ (HsOverLabel{}) = panic "dsExpr: HsOverLabel"
-ds_expr _ (HsLit lit) = dsLit lit
+ds_expr _ (HsLit lit) = dsLit (convertLit lit)
ds_expr _ (HsOverLit lit) = dsOverLit lit
ds_expr _ (HsWrap co_fn e)
@@ -632,7 +633,7 @@ ds_expr _ expr@(RecordUpd { rupd_expr = record_expr, rupd_flds = fields
; return (add_field_binds field_binds' $
bindNonRec discrim_var record_expr' matching_code) }
where
- ds_field :: LHsRecUpdField Id -> DsM (Name, Id, CoreExpr)
+ ds_field :: LHsRecUpdField GhcTc -> DsM (Name, Id, CoreExpr)
-- Clone the Id in the HsRecField, because its Name is that
-- of the record selector, and we must not make that a local binder
-- else we shadow other uses of the record selector
@@ -768,7 +769,7 @@ ds_expr _ (HsDo {}) = panic "dsExpr:HsDo"
ds_expr _ (HsRecFld {}) = panic "dsExpr:HsRecFld"
------------------------------
-dsSyntaxExpr :: SyntaxExpr Id -> [CoreExpr] -> DsM CoreExpr
+dsSyntaxExpr :: SyntaxExpr GhcTc -> [CoreExpr] -> DsM CoreExpr
dsSyntaxExpr (SyntaxExpr { syn_expr = expr
, syn_arg_wraps = arg_wraps
, syn_res_wrap = res_wrap })
@@ -782,7 +783,7 @@ dsSyntaxExpr (SyntaxExpr { syn_expr = expr
where
mk_doc n = text "In the" <+> speakNth n <+> text "argument of" <+> quotes (ppr expr)
-findField :: [LHsRecField Id arg] -> Name -> [arg]
+findField :: [LHsRecField GhcTc arg] -> Name -> [arg]
findField rbinds sel
= [hsRecFieldArg fld | L _ fld <- rbinds
, sel == idName (unLoc $ hsRecFieldId fld) ]
@@ -847,7 +848,7 @@ time.
maxBuildLength :: Int
maxBuildLength = 32
-dsExplicitList :: Type -> Maybe (SyntaxExpr Id) -> [LHsExpr Id]
+dsExplicitList :: Type -> Maybe (SyntaxExpr GhcTc) -> [LHsExpr GhcTc]
-> DsM CoreExpr
-- See Note [Desugaring explicit lists]
dsExplicitList elt_ty Nothing xs
@@ -871,7 +872,7 @@ dsExplicitList elt_ty (Just fln) xs
; dflags <- getDynFlags
; dsSyntaxExpr fln [mkIntExprInt dflags (length xs), list] }
-dsArithSeq :: PostTcExpr -> (ArithSeqInfo Id) -> DsM CoreExpr
+dsArithSeq :: PostTcExpr -> (ArithSeqInfo GhcTc) -> DsM CoreExpr
dsArithSeq expr (From from)
= App <$> dsExpr expr <*> dsLExprNoLP from
dsArithSeq expr (FromTo from to)
@@ -898,7 +899,7 @@ handled in DsListComp). Basically does the translation given in the
Haskell 98 report:
-}
-dsDo :: [ExprLStmt Id] -> DsM CoreExpr
+dsDo :: [ExprLStmt GhcTc] -> DsM CoreExpr
dsDo stmts
= goL stmts
where
@@ -994,7 +995,7 @@ dsDo stmts
go _ (ParStmt {}) _ = panic "dsDo ParStmt"
go _ (TransStmt {}) _ = panic "dsDo TransStmt"
-handle_failure :: LPat Id -> MatchResult -> SyntaxExpr Id -> DsM CoreExpr
+handle_failure :: LPat GhcTc -> MatchResult -> SyntaxExpr GhcTc -> DsM CoreExpr
-- In a do expression, pattern-match failure just calls
-- the monadic 'fail' rather than throwing an exception
handle_failure pat match fail_op
@@ -1052,7 +1053,7 @@ dsConLike _ (PatSynCon ps) = return $ case patSynBuilder ps of
-}
-- Warn about certain types of values discarded in monadic bindings (#3263)
-warnDiscardedDoBindings :: LHsExpr Id -> Type -> DsM ()
+warnDiscardedDoBindings :: LHsExpr GhcTc -> Type -> DsM ()
warnDiscardedDoBindings rhs rhs_ty
| Just (m_ty, elt_ty) <- tcSplitAppTy_maybe rhs_ty
= do { warn_unused <- woptM Opt_WarnUnusedDoBind
@@ -1080,7 +1081,7 @@ warnDiscardedDoBindings rhs rhs_ty
| otherwise -- RHS does have type of form (m ty), which is weird
= return () -- but at lesat this warning is irrelevant
-badMonadBind :: LHsExpr Id -> Type -> SDoc
+badMonadBind :: LHsExpr GhcTc -> Type -> SDoc
badMonadBind rhs elt_ty
= vcat [ hang (text "A do-notation statement discarded a result of type")
2 (quotes (ppr elt_ty))
@@ -1143,7 +1144,7 @@ we're not directly in an HsWrap, reject.
-- | Takes an expression and its instantiated type. If the expression is an
-- HsVar with a hasNoBinding primop and the type has levity-polymorphic arguments,
-- issue an error. See Note [Detecting forced eta expansion]
-checkForcedEtaExpansion :: HsExpr Id -> Type -> DsM ()
+checkForcedEtaExpansion :: HsExpr GhcTc -> Type -> DsM ()
checkForcedEtaExpansion expr ty
| Just var <- case expr of
HsVar (L _ var) -> Just var
diff --git a/compiler/deSugar/DsExpr.hs-boot b/compiler/deSugar/DsExpr.hs-boot
index 864df833a7..65c4f188fd 100644
--- a/compiler/deSugar/DsExpr.hs-boot
+++ b/compiler/deSugar/DsExpr.hs-boot
@@ -1,10 +1,10 @@
module DsExpr where
-import HsSyn ( HsExpr, LHsExpr, LHsLocalBinds, SyntaxExpr )
-import Var ( Id )
-import DsMonad ( DsM )
-import CoreSyn ( CoreExpr )
+import HsSyn ( HsExpr, LHsExpr, LHsLocalBinds, SyntaxExpr )
+import DsMonad ( DsM )
+import CoreSyn ( CoreExpr )
+import HsExtension ( GhcTc)
-dsExpr :: HsExpr Id -> DsM CoreExpr
-dsLExpr, dsLExprNoLP :: LHsExpr Id -> DsM CoreExpr
-dsSyntaxExpr :: SyntaxExpr Id -> [CoreExpr] -> DsM CoreExpr
-dsLocalBinds :: LHsLocalBinds Id -> CoreExpr -> DsM CoreExpr
+dsExpr :: HsExpr GhcTc -> DsM CoreExpr
+dsLExpr, dsLExprNoLP :: LHsExpr GhcTc -> DsM CoreExpr
+dsSyntaxExpr :: SyntaxExpr GhcTc -> [CoreExpr] -> DsM CoreExpr
+dsLocalBinds :: LHsLocalBinds GhcTc -> CoreExpr -> DsM CoreExpr
diff --git a/compiler/deSugar/DsForeign.hs b/compiler/deSugar/DsForeign.hs
index 9998a4d419..fb3752d104 100644
--- a/compiler/deSugar/DsForeign.hs
+++ b/compiler/deSugar/DsForeign.hs
@@ -7,6 +7,8 @@ Desugaring foreign declarations (see also DsCCall).
-}
{-# LANGUAGE CPP #-}
+{-# LANGUAGE FlexibleContexts #-}
+{-# LANGUAGE TypeFamilies #-}
module DsForeign ( dsForeigns ) where
@@ -69,14 +71,14 @@ is the same as
so we reuse the desugaring code in @DsCCall@ to deal with these.
-}
-type Binding = (Id, CoreExpr) -- No rec/nonrec structure;
- -- the occurrence analyser will sort it all out
+type Binding = (Id, CoreExpr) -- No rec/nonrec structure;
+ -- the occurrence analyser will sort it all out
-dsForeigns :: [LForeignDecl Id]
+dsForeigns :: [LForeignDecl GhcTc]
-> DsM (ForeignStubs, OrdList Binding)
dsForeigns fos = getHooked dsForeignsHook dsForeigns' >>= ($ fos)
-dsForeigns' :: [LForeignDecl Id]
+dsForeigns' :: [LForeignDecl GhcTc]
-> DsM (ForeignStubs, OrdList Binding)
dsForeigns' []
= return (NoStubs, nilOL)
diff --git a/compiler/deSugar/DsGRHSs.hs b/compiler/deSugar/DsGRHSs.hs
index e66461259d..c3dcdf6879 100644
--- a/compiler/deSugar/DsGRHSs.hs
+++ b/compiler/deSugar/DsGRHSs.hs
@@ -18,7 +18,6 @@ import {-# SOURCE #-} Match ( matchSinglePat )
import HsSyn
import MkCore
import CoreSyn
-import Var
import DsMonad
import DsUtils
@@ -44,7 +43,7 @@ producing an expression with a runtime error in the corner if
necessary. The type argument gives the type of the @ei@.
-}
-dsGuarded :: GRHSs Id (LHsExpr Id) -> Type -> DsM CoreExpr
+dsGuarded :: GRHSs GhcTc (LHsExpr GhcTc) -> Type -> DsM CoreExpr
dsGuarded grhss rhs_ty = do
match_result <- dsGRHSs PatBindRhs grhss rhs_ty
@@ -54,7 +53,7 @@ dsGuarded grhss rhs_ty = do
-- In contrast, @dsGRHSs@ produces a @MatchResult@.
dsGRHSs :: HsMatchContext Name
- -> GRHSs Id (LHsExpr Id) -- Guarded RHSs
+ -> GRHSs GhcTc (LHsExpr GhcTc) -- Guarded RHSs
-> Type -- Type of RHS
-> DsM MatchResult
dsGRHSs hs_ctx (GRHSs grhss binds) rhs_ty
@@ -65,7 +64,8 @@ dsGRHSs hs_ctx (GRHSs grhss binds) rhs_ty
-- NB: nested dsLet inside matchResult
; return match_result2 }
-dsGRHS :: HsMatchContext Name -> Type -> LGRHS Id (LHsExpr Id) -> DsM MatchResult
+dsGRHS :: HsMatchContext Name -> Type -> LGRHS GhcTc (LHsExpr GhcTc)
+ -> DsM MatchResult
dsGRHS hs_ctx rhs_ty (L _ (GRHS guards rhs))
= matchGuards (map unLoc guards) (PatGuard hs_ctx) rhs rhs_ty
@@ -77,10 +77,10 @@ dsGRHS hs_ctx rhs_ty (L _ (GRHS guards rhs))
************************************************************************
-}
-matchGuards :: [GuardStmt Id] -- Guard
- -> HsStmtContext Name -- Context
- -> LHsExpr Id -- RHS
- -> Type -- Type of RHS of guard
+matchGuards :: [GuardStmt GhcTc] -- Guard
+ -> HsStmtContext Name -- Context
+ -> LHsExpr GhcTc -- RHS
+ -> Type -- Type of RHS of guard
-> DsM MatchResult
-- See comments with HsExpr.Stmt re what a BodyStmt means
@@ -126,7 +126,7 @@ matchGuards (RecStmt {} : _) _ _ _ = panic "matchGuards RecStmt"
matchGuards (ApplicativeStmt {} : _) _ _ _ =
panic "matchGuards ApplicativeLastStmt"
-isTrueLHsExpr :: LHsExpr Id -> Maybe (CoreExpr -> DsM CoreExpr)
+isTrueLHsExpr :: LHsExpr GhcTc -> Maybe (CoreExpr -> DsM CoreExpr)
-- Returns Just {..} if we're sure that the expression is True
-- I.e. * 'True' datacon
diff --git a/compiler/deSugar/DsListComp.hs b/compiler/deSugar/DsListComp.hs
index 2bb303ec98..dc24183537 100644
--- a/compiler/deSugar/DsListComp.hs
+++ b/compiler/deSugar/DsListComp.hs
@@ -7,6 +7,7 @@ Desugaring list comprehensions, monad comprehensions and array comprehensions
-}
{-# LANGUAGE CPP, NamedFieldPuns #-}
+{-# LANGUAGE TypeFamilies #-}
module DsListComp ( dsListComp, dsPArrComp, dsMonadComp ) where
@@ -43,7 +44,7 @@ turned on'' (if you read Gill {\em et al.}'s paper on the subject).
There will be at least one ``qualifier'' in the input.
-}
-dsListComp :: [ExprLStmt Id]
+dsListComp :: [ExprLStmt GhcTc]
-> Type -- Type of entire list
-> DsM CoreExpr
dsListComp lquals res_ty = do
@@ -78,7 +79,7 @@ dsListComp lquals res_ty = do
-- This function lets you desugar a inner list comprehension and a list of the binders
-- of that comprehension that we need in the outer comprehension into such an expression
-- and the type of the elements that it outputs (tuples of binders)
-dsInnerListComp :: (ParStmtBlock Id Id) -> DsM (CoreExpr, Type)
+dsInnerListComp :: (ParStmtBlock GhcTc GhcTc) -> DsM (CoreExpr, Type)
dsInnerListComp (ParStmtBlock stmts bndrs _)
= do { let bndrs_tuple_type = mkBigCoreVarTupTy bndrs
list_ty = mkListTy bndrs_tuple_type
@@ -91,7 +92,7 @@ dsInnerListComp (ParStmtBlock stmts bndrs _)
-- This function factors out commonality between the desugaring strategies for GroupStmt.
-- Given such a statement it gives you back an expression representing how to compute the transformed
-- list and the tuple that you need to bind from that list in order to proceed with your desugaring
-dsTransStmt :: ExprStmt Id -> DsM (CoreExpr, LPat Id)
+dsTransStmt :: ExprStmt GhcTc -> DsM (CoreExpr, LPat GhcTc)
dsTransStmt (TransStmt { trS_form = form, trS_stmts = stmts, trS_bndrs = binderMap
, trS_by = by, trS_using = using }) = do
let (from_bndrs, to_bndrs) = unzip binderMap
@@ -211,7 +212,7 @@ The introduced tuples are Boxed, but only because I couldn't get it to work
with the Unboxed variety.
-}
-deListComp :: [ExprStmt Id] -> CoreExpr -> DsM CoreExpr
+deListComp :: [ExprStmt GhcTc] -> CoreExpr -> DsM CoreExpr
deListComp [] _ = panic "deListComp"
@@ -261,9 +262,9 @@ deListComp (RecStmt {} : _) _ = panic "deListComp RecStmt"
deListComp (ApplicativeStmt {} : _) _ =
panic "deListComp ApplicativeStmt"
-deBindComp :: OutPat Id
+deBindComp :: OutPat GhcTc
-> CoreExpr
- -> [ExprStmt Id]
+ -> [ExprStmt GhcTc]
-> CoreExpr
-> DsM (Expr Id)
deBindComp pat core_list1 quals core_list2 = do
@@ -317,8 +318,8 @@ TE[ e | p <- l , q ] c n = let
\end{verbatim}
-}
-dfListComp :: Id -> Id -- 'c' and 'n'
- -> [ExprStmt Id] -- the rest of the qual's
+dfListComp :: Id -> Id -- 'c' and 'n'
+ -> [ExprStmt GhcTc] -- the rest of the qual's
-> DsM CoreExpr
dfListComp _ _ [] = panic "dfListComp"
@@ -356,9 +357,9 @@ dfListComp _ _ (RecStmt {} : _) = panic "dfListComp RecStmt"
dfListComp _ _ (ApplicativeStmt {} : _) =
panic "dfListComp ApplicativeStmt"
-dfBindComp :: Id -> Id -- 'c' and 'n'
- -> (LPat Id, CoreExpr)
- -> [ExprStmt Id] -- the rest of the qual's
+dfBindComp :: Id -> Id -- 'c' and 'n'
+ -> (LPat GhcTc, CoreExpr)
+ -> [ExprStmt GhcTc] -- the rest of the qual's
-> DsM CoreExpr
dfBindComp c_id n_id (pat, core_list1) quals = do
-- find the required type
@@ -478,7 +479,7 @@ mkUnzipBind _ elt_tys
--
-- [:e | qss:] = <<[:e | qss:]>> () [:():]
--
-dsPArrComp :: [ExprStmt Id]
+dsPArrComp :: [ExprStmt GhcTc]
-> DsM CoreExpr
-- Special case for parallel comprehension
@@ -514,8 +515,8 @@ dsPArrComp qs = do -- no ParStmt in `qs'
-- the work horse
--
-dePArrComp :: [ExprStmt Id]
- -> LPat Id -- the current generator pattern
+dePArrComp :: [ExprStmt GhcTc]
+ -> LPat GhcTc -- the current generator pattern
-> CoreExpr -- the current generator expression
-> DsM CoreExpr
@@ -612,7 +613,7 @@ dePArrComp (ApplicativeStmt {} : _) _ _ =
-- where
-- {x_1, ..., x_n} = DV (qs)
--
-dePArrParComp :: [ParStmtBlock Id Id] -> [ExprStmt Id] -> DsM CoreExpr
+dePArrParComp :: [ParStmtBlock GhcTc GhcTc] -> [ExprStmt GhcTc] -> DsM CoreExpr
dePArrParComp qss quals = do
(pQss, ceQss) <- deParStmt qss
dePArrComp quals pQss ceQss
@@ -639,8 +640,8 @@ dePArrParComp qss quals = do
-- generate Core corresponding to `\p -> e'
--
deLambda :: Type -- type of the argument (not levity-polymorphic)
- -> LPat Id -- argument pattern
- -> LHsExpr Id -- body
+ -> LPat GhcTc -- argument pattern
+ -> LHsExpr GhcTc -- body
-> DsM (CoreExpr, Type)
deLambda ty p e =
mkLambda ty p =<< dsLExpr e
@@ -648,7 +649,7 @@ deLambda ty p e =
-- generate Core for a lambda pattern match, where the body is already in Core
--
mkLambda :: Type -- type of the argument (not levity-polymorphic)
- -> LPat Id -- argument pattern
+ -> LPat GhcTc -- argument pattern
-> CoreExpr -- desugared body
-> DsM (CoreExpr, Type)
mkLambda ty p ce = do
@@ -672,15 +673,15 @@ parrElemType e =
-- Translation for monad comprehensions
-- Entry point for monad comprehension desugaring
-dsMonadComp :: [ExprLStmt Id] -> DsM CoreExpr
+dsMonadComp :: [ExprLStmt GhcTc] -> DsM CoreExpr
dsMonadComp stmts = dsMcStmts stmts
-dsMcStmts :: [ExprLStmt Id] -> DsM CoreExpr
+dsMcStmts :: [ExprLStmt GhcTc] -> DsM CoreExpr
dsMcStmts [] = panic "dsMcStmts"
dsMcStmts (L loc stmt : lstmts) = putSrcSpanDs loc (dsMcStmt stmt lstmts)
---------------
-dsMcStmt :: ExprStmt Id -> [ExprLStmt Id] -> DsM CoreExpr
+dsMcStmt :: ExprStmt GhcTc -> [ExprLStmt GhcTc] -> DsM CoreExpr
dsMcStmt (LastStmt body _ ret_op) stmts
= ASSERT( null stmts )
@@ -803,12 +804,12 @@ matchTuple ids body
-- general `rhs' >>= \pat -> stmts` desugaring where `rhs'` is already a
-- desugared `CoreExpr`
-dsMcBindStmt :: LPat Id
+dsMcBindStmt :: LPat GhcTc
-> CoreExpr -- ^ the desugared rhs of the bind statement
- -> SyntaxExpr Id
- -> SyntaxExpr Id
+ -> SyntaxExpr GhcTc
+ -> SyntaxExpr GhcTc
-> Type -- ^ S in (>>=) :: Q -> (R -> S) -> T
- -> [ExprLStmt Id]
+ -> [ExprLStmt GhcTc]
-> DsM CoreExpr
dsMcBindStmt pat rhs' bind_op fail_op res1_ty stmts
= do { body <- dsMcStmts stmts
@@ -840,9 +841,9 @@ dsMcBindStmt pat rhs' bind_op fail_op res1_ty stmts
-- returns the desugaring of
-- [ (a,b,c) | quals ]
-dsInnerMonadComp :: [ExprLStmt Id]
- -> [Id] -- Return a tuple of these variables
- -> SyntaxExpr Id -- The monomorphic "return" operator
+dsInnerMonadComp :: [ExprLStmt GhcTc]
+ -> [Id] -- Return a tuple of these variables
+ -> SyntaxExpr GhcTc -- The monomorphic "return" operator
-> DsM CoreExpr
dsInnerMonadComp stmts bndrs ret_op
= dsMcStmts (stmts ++ [noLoc (LastStmt (mkBigLHsVarTupId bndrs) False ret_op)])
@@ -860,7 +861,7 @@ dsInnerMonadComp stmts bndrs ret_op
-- , fmap (selN2 :: (t1, t2) -> t2) ys )
mkMcUnzipM :: TransForm
- -> HsExpr TcId -- fmap
+ -> HsExpr GhcTcId -- fmap
-> Id -- Of type n (a,b,c)
-> [Type] -- [a,b,c] (not levity-polymorphic)
-> DsM CoreExpr -- Of type (n a, n b, n c)
diff --git a/compiler/deSugar/DsMeta.hs b/compiler/deSugar/DsMeta.hs
index bb4361e34a..f7f2fd597e 100644
--- a/compiler/deSugar/DsMeta.hs
+++ b/compiler/deSugar/DsMeta.hs
@@ -1,4 +1,5 @@
{-# LANGUAGE CPP, TypeFamilies #-}
+{-# LANGUAGE FlexibleContexts #-}
-----------------------------------------------------------------------------
--
@@ -64,7 +65,7 @@ import Control.Monad
import Data.List
-----------------------------------------------------------------------------
-dsBracket :: HsBracket Name -> [PendingTcSplice] -> DsM CoreExpr
+dsBracket :: HsBracket GhcRn -> [PendingTcSplice] -> DsM CoreExpr
-- Returns a CoreExpr of type TH.ExpQ
-- The quoted thing is parameterised over Name, even though it has
-- been type checked. We don't want all those type decorations!
@@ -101,12 +102,12 @@ dsBracket brack splices
-- Declarations
-------------------------------------------------------
-repTopP :: LPat Name -> DsM (Core TH.PatQ)
+repTopP :: LPat GhcRn -> DsM (Core TH.PatQ)
repTopP pat = do { ss <- mkGenSyms (collectPatBinders pat)
; pat' <- addBinds ss (repLP pat)
; wrapGenSyms ss pat' }
-repTopDs :: HsGroup Name -> DsM (Core (TH.Q [TH.Dec]))
+repTopDs :: HsGroup GhcRn -> DsM (Core (TH.Q [TH.Dec]))
repTopDs group@(HsGroup { hs_valds = valds
, hs_splcds = splcds
, hs_tyclds = tyclds
@@ -178,12 +179,12 @@ repTopDs group@(HsGroup { hs_valds = valds
no_doc (L loc _)
= notHandledL loc "Haddock documentation" empty
-hsSigTvBinders :: HsValBinds Name -> [Name]
+hsSigTvBinders :: HsValBinds GhcRn -> [Name]
-- See Note [Scoped type variables in bindings]
hsSigTvBinders binds
= concatMap get_scoped_tvs sigs
where
- get_scoped_tvs :: LSig Name -> [Name]
+ get_scoped_tvs :: LSig GhcRn -> [Name]
-- Both implicit and explicit quantified variables
-- We need the implicit ones for f :: forall (a::k). blah
-- here 'k' scopes too
@@ -262,7 +263,7 @@ them into a `ForallT` or `ForallC`. Doing so caused #13018 and #13123.
-- represent associated family instances
--
-repTyClD :: LTyClDecl Name -> DsM (Maybe (SrcSpan, Core TH.DecQ))
+repTyClD :: LTyClDecl GhcRn -> DsM (Maybe (SrcSpan, Core TH.DecQ))
repTyClD (L loc (FamDecl { tcdFam = fam })) = liftM Just $ repFamilyDecl (L loc fam)
@@ -297,7 +298,7 @@ repTyClD (L loc (ClassDecl { tcdCtxt = cxt, tcdLName = cls,
}
-------------------------
-repRoleD :: LRoleAnnotDecl Name -> DsM (SrcSpan, Core TH.DecQ)
+repRoleD :: LRoleAnnotDecl GhcRn -> DsM (SrcSpan, Core TH.DecQ)
repRoleD (L loc (RoleAnnotDecl tycon roles))
= do { tycon1 <- lookupLOcc tycon
; roles1 <- mapM repRole roles
@@ -308,7 +309,7 @@ repRoleD (L loc (RoleAnnotDecl tycon roles))
-------------------------
repDataDefn :: Core TH.Name -> Core [TH.TyVarBndr]
-> Maybe (Core [TH.TypeQ])
- -> HsDataDefn Name
+ -> HsDataDefn GhcRn
-> DsM (Core TH.DecQ)
repDataDefn tc bndrs opt_tys
(HsDataDefn { dd_ND = new_or_data, dd_ctxt = cxt, dd_kindSig = ksig
@@ -331,20 +332,20 @@ repDataDefn tc bndrs opt_tys
}
repSynDecl :: Core TH.Name -> Core [TH.TyVarBndr]
- -> LHsType Name
+ -> LHsType GhcRn
-> DsM (Core TH.DecQ)
repSynDecl tc bndrs ty
= do { ty1 <- repLTy ty
; repTySyn tc bndrs ty1 }
-repFamilyDecl :: LFamilyDecl Name -> DsM (SrcSpan, Core TH.DecQ)
+repFamilyDecl :: LFamilyDecl GhcRn -> DsM (SrcSpan, Core TH.DecQ)
repFamilyDecl decl@(L loc (FamilyDecl { fdInfo = info,
fdLName = tc,
fdTyVars = tvs,
fdResultSig = L _ resultSig,
fdInjectivityAnn = injectivity }))
= do { tc1 <- lookupLOcc tc -- See note [Binders and occurrences]
- ; let mkHsQTvs :: [LHsTyVarBndr Name] -> LHsQTyVars Name
+ ; let mkHsQTvs :: [LHsTyVarBndr GhcRn] -> LHsQTyVars GhcRn
mkHsQTvs tvs = HsQTvs { hsq_implicit = [], hsq_explicit = tvs
, hsq_dependent = emptyNameSet }
resTyVar = case resultSig of
@@ -372,7 +373,7 @@ repFamilyDecl decl@(L loc (FamilyDecl { fdInfo = info,
}
-- | Represent result signature of a type family
-repFamilyResultSig :: FamilyResultSig Name -> DsM (Core TH.FamilyResultSig)
+repFamilyResultSig :: FamilyResultSig GhcRn -> DsM (Core TH.FamilyResultSig)
repFamilyResultSig NoSig = repNoSig
repFamilyResultSig (KindSig ki) = do { ki' <- repLKind ki
; repKindSig ki' }
@@ -382,7 +383,7 @@ repFamilyResultSig (TyVarSig bndr) = do { bndr' <- repTyVarBndr bndr
-- | Represent result signature using a Maybe Kind. Used with data families,
-- where the result signature can be either missing or a kind but never a named
-- result variable.
-repFamilyResultSigToMaybeKind :: FamilyResultSig Name
+repFamilyResultSigToMaybeKind :: FamilyResultSig GhcRn
-> DsM (Core (Maybe TH.Kind))
repFamilyResultSigToMaybeKind NoSig =
do { coreNothing kindTyConName }
@@ -392,7 +393,7 @@ repFamilyResultSigToMaybeKind (KindSig ki) =
repFamilyResultSigToMaybeKind _ = panic "repFamilyResultSigToMaybeKind"
-- | Represent injectivity annotation of a type family
-repInjectivityAnn :: Maybe (LInjectivityAnn Name)
+repInjectivityAnn :: Maybe (LInjectivityAnn GhcRn)
-> DsM (Core (Maybe TH.InjectivityAnn))
repInjectivityAnn Nothing =
do { coreNothing injAnnTyConName }
@@ -403,14 +404,14 @@ repInjectivityAnn (Just (L _ (InjectivityAnn lhs rhs))) =
; injAnn <- rep2 injectivityAnnName [unC lhs', unC rhs2]
; coreJust injAnnTyConName injAnn }
-repFamilyDecls :: [LFamilyDecl Name] -> DsM [Core TH.DecQ]
+repFamilyDecls :: [LFamilyDecl GhcRn] -> DsM [Core TH.DecQ]
repFamilyDecls fds = liftM de_loc (mapM repFamilyDecl fds)
-repAssocTyFamDefaults :: [LTyFamDefltEqn Name] -> DsM [Core TH.DecQ]
+repAssocTyFamDefaults :: [LTyFamDefltEqn GhcRn] -> DsM [Core TH.DecQ]
repAssocTyFamDefaults = mapM rep_deflt
where
-- very like repTyFamEqn, but different in the details
- rep_deflt :: LTyFamDefltEqn Name -> DsM (Core TH.DecQ)
+ rep_deflt :: LTyFamDefltEqn GhcRn -> DsM (Core TH.DecQ)
rep_deflt (L _ (TyFamEqn { tfe_tycon = tc
, tfe_pats = bndrs
, tfe_rhs = rhs }))
@@ -436,7 +437,7 @@ repLFunDep (L _ (xs, ys))
-- Represent instance declarations
--
-repInstD :: LInstDecl Name -> DsM (SrcSpan, Core TH.DecQ)
+repInstD :: LInstDecl GhcRn -> DsM (SrcSpan, Core TH.DecQ)
repInstD (L loc (TyFamInstD { tfid_inst = fi_decl }))
= do { dec <- repTyFamInstD fi_decl
; return (loc, dec) }
@@ -447,7 +448,7 @@ repInstD (L loc (ClsInstD { cid_inst = cls_decl }))
= do { dec <- repClsInstD cls_decl
; return (loc, dec) }
-repClsInstD :: ClsInstDecl Name -> DsM (Core TH.DecQ)
+repClsInstD :: ClsInstDecl GhcRn -> DsM (Core TH.DecQ)
repClsInstD (ClsInstDecl { cid_poly_ty = ty, cid_binds = binds
, cid_sigs = prags, cid_tyfam_insts = ats
, cid_datafam_insts = adts
@@ -475,7 +476,7 @@ repClsInstD (ClsInstDecl { cid_poly_ty = ty, cid_binds = binds
where
(tvs, cxt, inst_ty) = splitLHsInstDeclTy ty
-repStandaloneDerivD :: LDerivDecl Name -> DsM (SrcSpan, Core TH.DecQ)
+repStandaloneDerivD :: LDerivDecl GhcRn -> DsM (SrcSpan, Core TH.DecQ)
repStandaloneDerivD (L loc (DerivDecl { deriv_strategy = strat
, deriv_type = ty }))
= do { dec <- addSimpleTyVarBinds tvs $
@@ -487,14 +488,14 @@ repStandaloneDerivD (L loc (DerivDecl { deriv_strategy = strat
where
(tvs, cxt, inst_ty) = splitLHsInstDeclTy ty
-repTyFamInstD :: TyFamInstDecl Name -> DsM (Core TH.DecQ)
+repTyFamInstD :: TyFamInstDecl GhcRn -> DsM (Core TH.DecQ)
repTyFamInstD decl@(TyFamInstDecl { tfid_eqn = eqn })
= do { let tc_name = tyFamInstDeclLName decl
; tc <- lookupLOcc tc_name -- See note [Binders and occurrences]
; eqn1 <- repTyFamEqn eqn
; repTySynInst tc eqn1 }
-repTyFamEqn :: LTyFamInstEqn Name -> DsM (Core TH.TySynEqnQ)
+repTyFamEqn :: LTyFamInstEqn GhcRn -> DsM (Core TH.TySynEqnQ)
repTyFamEqn (L _ (TyFamEqn { tfe_pats = HsIB { hsib_body = tys
, hsib_vars = var_names }
, tfe_rhs = rhs }))
@@ -507,7 +508,7 @@ repTyFamEqn (L _ (TyFamEqn { tfe_pats = HsIB { hsib_body = tys
; rhs1 <- repLTy rhs
; repTySynEqn tys2 rhs1 } }
-repDataFamInstD :: DataFamInstDecl Name -> DsM (Core TH.DecQ)
+repDataFamInstD :: DataFamInstDecl GhcRn -> DsM (Core TH.DecQ)
repDataFamInstD (DataFamInstDecl { dfid_tycon = tc_name
, dfid_pats = HsIB { hsib_body = tys, hsib_vars = var_names }
, dfid_defn = defn })
@@ -519,7 +520,7 @@ repDataFamInstD (DataFamInstDecl { dfid_tycon = tc_name
do { tys1 <- repList typeQTyConName repLTy tys
; repDataDefn tc bndrs (Just tys1) defn } }
-repForD :: Located (ForeignDecl Name) -> DsM (SrcSpan, Core TH.DecQ)
+repForD :: Located (ForeignDecl GhcRn) -> DsM (SrcSpan, Core TH.DecQ)
repForD (L loc (ForeignImport { fd_name = name, fd_sig_ty = typ
, fd_fi = CImport (L _ cc) (L _ s) mch cis _ }))
= do MkC name' <- lookupLOcc name
@@ -560,7 +561,7 @@ repSafety PlayRisky = rep2 unsafeName []
repSafety PlayInterruptible = rep2 interruptibleName []
repSafety PlaySafe = rep2 safeName []
-repFixD :: LFixitySig Name -> DsM [(SrcSpan, Core TH.DecQ)]
+repFixD :: LFixitySig GhcRn -> DsM [(SrcSpan, Core TH.DecQ)]
repFixD (L loc (FixitySig names (Fixity _ prec dir)))
= do { MkC prec' <- coreIntLit prec
; let rep_fn = case dir of
@@ -573,7 +574,7 @@ repFixD (L loc (FixitySig names (Fixity _ prec dir)))
; return (loc,dec) }
; mapM do_one names }
-repRuleD :: LRuleDecl Name -> DsM (SrcSpan, Core TH.DecQ)
+repRuleD :: LRuleDecl GhcRn -> DsM (SrcSpan, Core TH.DecQ)
repRuleD (L loc (HsRule n act bndrs lhs _ rhs _))
= do { let bndr_names = concatMap ruleBndrNames bndrs
; ss <- mkGenSyms bndr_names
@@ -587,13 +588,13 @@ repRuleD (L loc (HsRule n act bndrs lhs _ rhs _))
; rule2 <- wrapGenSyms ss rule1
; return (loc, rule2) }
-ruleBndrNames :: LRuleBndr Name -> [Name]
+ruleBndrNames :: LRuleBndr GhcRn -> [Name]
ruleBndrNames (L _ (RuleBndr n)) = [unLoc n]
ruleBndrNames (L _ (RuleBndrSig n sig))
| HsWC { hswc_body = HsIB { hsib_vars = vars }} <- sig
= unLoc n : vars
-repRuleBndr :: LRuleBndr Name -> DsM (Core TH.RuleBndrQ)
+repRuleBndr :: LRuleBndr GhcRn -> DsM (Core TH.RuleBndrQ)
repRuleBndr (L _ (RuleBndr n))
= do { MkC n' <- lookupLBinder n
; rep2 ruleVarName [n'] }
@@ -602,7 +603,7 @@ repRuleBndr (L _ (RuleBndrSig n sig))
; MkC ty' <- repLTy (hsSigWcType sig)
; rep2 typedRuleVarName [n', ty'] }
-repAnnD :: LAnnDecl Name -> DsM (SrcSpan, Core TH.DecQ)
+repAnnD :: LAnnDecl GhcRn -> DsM (SrcSpan, Core TH.DecQ)
repAnnD (L loc (HsAnnotation _ ann_prov (L _ exp)))
= do { target <- repAnnProv ann_prov
; exp' <- repE exp
@@ -623,7 +624,7 @@ repAnnProv ModuleAnnProvenance
-- Constructors
-------------------------------------------------------
-repC :: LConDecl Name -> DsM (Core TH.ConQ)
+repC :: LConDecl GhcRn -> DsM (Core TH.ConQ)
repC (L _ (ConDeclH98 { con_name = con
, con_qvars = Nothing, con_cxt = Nothing
, con_details = details }))
@@ -681,7 +682,7 @@ repSrcStrictness SrcLazy = rep2 sourceLazyName []
repSrcStrictness SrcStrict = rep2 sourceStrictName []
repSrcStrictness NoSrcStrict = rep2 noSourceStrictnessName []
-repBangTy :: LBangType Name -> DsM (Core (TH.BangTypeQ))
+repBangTy :: LBangType GhcRn -> DsM (Core (TH.BangTypeQ))
repBangTy ty = do
MkC u <- repSrcUnpackedness su'
MkC s <- repSrcStrictness ss'
@@ -697,10 +698,10 @@ repBangTy ty = do
-- Deriving clauses
-------------------------------------------------------
-repDerivs :: HsDeriving Name -> DsM (Core [TH.DerivClauseQ])
+repDerivs :: HsDeriving GhcRn -> DsM (Core [TH.DerivClauseQ])
repDerivs (L _ clauses) = repList derivClauseQTyConName repDerivClause clauses
-repDerivClause :: LHsDerivingClause Name
+repDerivClause :: LHsDerivingClause GhcRn
-> DsM (Core TH.DerivClauseQ)
repDerivClause (L _ (HsDerivingClause { deriv_clause_strategy = dcs
, deriv_clause_tys = L _ dct }))
@@ -708,22 +709,22 @@ repDerivClause (L _ (HsDerivingClause { deriv_clause_strategy = dcs
MkC dct' <- repList typeQTyConName (rep_deriv_ty . hsSigType) dct
rep2 derivClauseName [dcs',dct']
where
- rep_deriv_ty :: LHsType Name -> DsM (Core TH.TypeQ)
+ rep_deriv_ty :: LHsType GhcRn -> DsM (Core TH.TypeQ)
rep_deriv_ty (L _ ty) = repTy ty
-------------------------------------------------------
-- Signatures in a class decl, or a group of bindings
-------------------------------------------------------
-rep_sigs :: [LSig Name] -> DsM [Core TH.DecQ]
+rep_sigs :: [LSig GhcRn] -> DsM [Core TH.DecQ]
rep_sigs sigs = do locs_cores <- rep_sigs' sigs
return $ de_loc $ sort_by_loc locs_cores
-rep_sigs' :: [LSig Name] -> DsM [(SrcSpan, Core TH.DecQ)]
+rep_sigs' :: [LSig GhcRn] -> DsM [(SrcSpan, Core TH.DecQ)]
-- We silently ignore ones we don't recognise
rep_sigs' = concatMapM rep_sig
-rep_sig :: LSig Name -> DsM [(SrcSpan, Core TH.DecQ)]
+rep_sig :: LSig GhcRn -> DsM [(SrcSpan, Core TH.DecQ)]
rep_sig (L loc (TypeSig nms ty)) = mapM (rep_wc_ty_sig sigDName loc ty) nms
rep_sig (L loc (PatSynSig nms ty)) = mapM (rep_patsyn_ty_sig loc ty) nms
rep_sig (L loc (ClassOpSig is_deflt nms ty))
@@ -740,7 +741,7 @@ rep_sig (L _ (SCCFunSig {})) = notHandled "SCC pragmas" empty
rep_sig (L loc (CompleteMatchSig _st cls mty)) = rep_complete_sig cls mty loc
-rep_ty_sig :: Name -> SrcSpan -> LHsSigType Name -> Located Name
+rep_ty_sig :: Name -> SrcSpan -> LHsSigType GhcRn -> Located Name
-> DsM (SrcSpan, Core TH.DecQ)
rep_ty_sig mk_sig loc sig_ty nm
= do { nm1 <- lookupLOcc nm
@@ -748,7 +749,7 @@ rep_ty_sig mk_sig loc sig_ty nm
; sig <- repProto mk_sig nm1 ty1
; return (loc, sig) }
-rep_patsyn_ty_sig :: SrcSpan -> LHsSigType Name -> Located Name
+rep_patsyn_ty_sig :: SrcSpan -> LHsSigType GhcRn -> Located Name
-> DsM (SrcSpan, Core TH.DecQ)
-- represents a pattern synonym type signature;
-- see Note [Pattern synonym type signatures and Template Haskell] in Convert
@@ -758,7 +759,7 @@ rep_patsyn_ty_sig loc sig_ty nm
; sig <- repProto patSynSigDName nm1 ty1
; return (loc, sig) }
-rep_wc_ty_sig :: Name -> SrcSpan -> LHsSigWcType Name -> Located Name
+rep_wc_ty_sig :: Name -> SrcSpan -> LHsSigWcType GhcRn -> Located Name
-> DsM (SrcSpan, Core TH.DecQ)
-- We must special-case the top-level explicit for-all of a TypeSig
-- See Note [Scoped type variables in bindings]
@@ -794,7 +795,8 @@ rep_inline nm ispec loc
; return [(loc, pragma)]
}
-rep_specialise :: Located Name -> LHsSigType Name -> InlinePragma -> SrcSpan
+rep_specialise :: Located Name -> LHsSigType GhcRn -> InlinePragma
+ -> SrcSpan
-> DsM [(SrcSpan, Core TH.DecQ)]
rep_specialise nm ty ispec loc
= do { nm1 <- lookupLOcc nm
@@ -810,7 +812,8 @@ rep_specialise nm ty ispec loc
; return [(loc, pragma)]
}
-rep_specialiseInst :: LHsSigType Name -> SrcSpan -> DsM [(SrcSpan, Core TH.DecQ)]
+rep_specialiseInst :: LHsSigType GhcRn -> SrcSpan
+ -> DsM [(SrcSpan, Core TH.DecQ)]
rep_specialiseInst ty loc
= do { ty1 <- repHsSigType ty
; pragma <- repPragSpecInst ty1
@@ -860,7 +863,7 @@ addSimpleTyVarBinds names thing_inside
; term <- addBinds fresh_names thing_inside
; wrapGenSyms fresh_names term }
-addTyVarBinds :: LHsQTyVars Name -- the binders to be added
+addTyVarBinds :: LHsQTyVars GhcRn -- the binders to be added
-> (Core [TH.TyVarBndr] -> DsM (Core (TH.Q a))) -- action in the ext env
-> DsM (Core (TH.Q a))
-- gensym a list of type variables and enter them into the meta environment;
@@ -879,7 +882,7 @@ addTyVarBinds (HsQTvs { hsq_implicit = imp_tvs, hsq_explicit = exp_tvs }) m
where
mk_tv_bndr (tv, (_,v)) = repTyVarBndrWithKind tv (coreVar v)
-addTyClTyVarBinds :: LHsQTyVars Name
+addTyClTyVarBinds :: LHsQTyVars GhcRn
-> (Core [TH.TyVarBndr] -> DsM (Core (TH.Q a)))
-> DsM (Core (TH.Q a))
@@ -906,7 +909,7 @@ addTyClTyVarBinds tvs m
-- Produce kinded binder constructors from the Haskell tyvar binders
--
-repTyVarBndrWithKind :: LHsTyVarBndr Name
+repTyVarBndrWithKind :: LHsTyVarBndr GhcRn
-> Core TH.Name -> DsM (Core TH.TyVarBndr)
repTyVarBndrWithKind (L _ (UserTyVar _)) nm
= repPlainTV nm
@@ -914,7 +917,7 @@ repTyVarBndrWithKind (L _ (KindedTyVar _ ki)) nm
= repLKind ki >>= repKindedTV nm
-- | Represent a type variable binder
-repTyVarBndr :: LHsTyVarBndr Name -> DsM (Core TH.TyVarBndr)
+repTyVarBndr :: LHsTyVarBndr GhcRn -> DsM (Core TH.TyVarBndr)
repTyVarBndr (L _ (UserTyVar (L _ nm)) )= do { nm' <- lookupBinder nm
; repPlainTV nm' }
repTyVarBndr (L _ (KindedTyVar (L _ nm) ki)) = do { nm' <- lookupBinder nm
@@ -923,14 +926,14 @@ repTyVarBndr (L _ (KindedTyVar (L _ nm) ki)) = do { nm' <- lookupBinder nm
-- represent a type context
--
-repLContext :: LHsContext Name -> DsM (Core TH.CxtQ)
+repLContext :: LHsContext GhcRn -> DsM (Core TH.CxtQ)
repLContext (L _ ctxt) = repContext ctxt
-repContext :: HsContext Name -> DsM (Core TH.CxtQ)
+repContext :: HsContext GhcRn -> DsM (Core TH.CxtQ)
repContext ctxt = do preds <- repList typeQTyConName repLTy ctxt
repCtxt preds
-repHsSigType :: LHsSigType Name -> DsM (Core TH.TypeQ)
+repHsSigType :: LHsSigType GhcRn -> DsM (Core TH.TypeQ)
repHsSigType (HsIB { hsib_vars = implicit_tvs
, hsib_body = body })
| (explicit_tvs, ctxt, ty) <- splitLHsSigmaTy body
@@ -946,7 +949,7 @@ repHsSigType (HsIB { hsib_vars = implicit_tvs
then return th_ty
else repTForall th_explicit_tvs th_ctxt th_ty }
-repHsPatSynSigType :: LHsSigType Name -> DsM (Core TH.TypeQ)
+repHsPatSynSigType :: LHsSigType GhcRn -> DsM (Core TH.TypeQ)
repHsPatSynSigType (HsIB { hsib_vars = implicit_tvs
, hsib_body = body })
= addTyVarBinds (newTvs implicit_tvs univs) $ \th_univs ->
@@ -965,19 +968,19 @@ repHsPatSynSigType (HsIB { hsib_vars = implicit_tvs
(univs, reqs, exis, provs, ty) = splitLHsPatSynTy body
-repHsSigWcType :: LHsSigWcType Name -> DsM (Core TH.TypeQ)
+repHsSigWcType :: LHsSigWcType GhcRn -> DsM (Core TH.TypeQ)
repHsSigWcType (HsWC { hswc_body = sig1 })
= repHsSigType sig1
-- yield the representation of a list of types
-repLTys :: [LHsType Name] -> DsM [Core TH.TypeQ]
+repLTys :: [LHsType GhcRn] -> DsM [Core TH.TypeQ]
repLTys tys = mapM repLTy tys
-- represent a type
-repLTy :: LHsType Name -> DsM (Core TH.TypeQ)
+repLTy :: LHsType GhcRn -> DsM (Core TH.TypeQ)
repLTy (L _ ty) = repTy ty
-repForall :: HsType Name -> DsM (Core TH.TypeQ)
+repForall :: HsType GhcRn -> DsM (Core TH.TypeQ)
-- Arg of repForall is always HsForAllTy or HsQualTy
repForall ty
| (tvs, ctxt, tau) <- splitLHsSigmaTy (noLoc ty)
@@ -987,7 +990,7 @@ repForall ty
; ty1 <- repLTy tau
; repTForall bndrs ctxt1 ty1 }
-repTy :: HsType Name -> DsM (Core TH.TypeQ)
+repTy :: HsType GhcRn -> DsM (Core TH.TypeQ)
repTy ty@(HsForAllTy {}) = repForall ty
repTy ty@(HsQualTy {}) = repForall ty
@@ -1066,7 +1069,7 @@ repTyLit (HsStrTy _ s) = do { s' <- mkStringExprFS s
-- represent a kind
--
-repLKind :: LHsKind Name -> DsM (Core TH.Kind)
+repLKind :: LHsKind GhcRn -> DsM (Core TH.Kind)
repLKind ki
= do { let (kis, ki') = splitHsFunType ki
; kis_rep <- mapM repLKind kis
@@ -1077,7 +1080,7 @@ repLKind ki
}
-- | Represent a kind wrapped in a Maybe
-repMaybeLKind :: Maybe (LHsKind Name)
+repMaybeLKind :: Maybe (LHsKind GhcRn)
-> DsM (Core (Maybe TH.Kind))
repMaybeLKind Nothing =
do { coreNothing kindTyConName }
@@ -1085,10 +1088,10 @@ repMaybeLKind (Just ki) =
do { ki' <- repLKind ki
; coreJust kindTyConName ki' }
-repNonArrowLKind :: LHsKind Name -> DsM (Core TH.Kind)
+repNonArrowLKind :: LHsKind GhcRn -> DsM (Core TH.Kind)
repNonArrowLKind (L _ ki) = repNonArrowKind ki
-repNonArrowKind :: HsKind Name -> DsM (Core TH.Kind)
+repNonArrowKind :: HsKind GhcRn -> DsM (Core TH.Kind)
repNonArrowKind (HsTyVar _ (L _ name))
| isLiftedTypeKindTyConName name = repKStar
| name `hasKey` constraintKindTyConKey = repKConstraint
@@ -1118,7 +1121,7 @@ repRole (L _ Nothing) = rep2 inferRName []
-- Splices
-----------------------------------------------------------------------------
-repSplice :: HsSplice Name -> DsM (Core a)
+repSplice :: HsSplice GhcRn -> DsM (Core a)
-- See Note [How brackets and nested splices are handled] in TcSplice
-- We return a CoreExpr of any old type; the context should know
repSplice (HsTypedSplice _ n _) = rep_splice n
@@ -1139,16 +1142,16 @@ rep_splice splice_name
-- Expressions
-----------------------------------------------------------------------------
-repLEs :: [LHsExpr Name] -> DsM (Core [TH.ExpQ])
+repLEs :: [LHsExpr GhcRn] -> DsM (Core [TH.ExpQ])
repLEs es = repList expQTyConName repLE es
-- FIXME: some of these panics should be converted into proper error messages
-- unless we can make sure that constructs, which are plainly not
-- supported in TH already lead to error messages at an earlier stage
-repLE :: LHsExpr Name -> DsM (Core TH.ExpQ)
+repLE :: LHsExpr GhcRn -> DsM (Core TH.ExpQ)
repLE (L loc e) = putSrcSpanDs loc (repE e)
-repE :: HsExpr Name -> DsM (Core TH.ExpQ)
+repE :: HsExpr GhcRn -> DsM (Core TH.ExpQ)
repE (HsVar (L _ x)) =
do { mb_val <- dsLookupMetaEnv x
; case mb_val of
@@ -1284,7 +1287,7 @@ repE e = notHandled "Expression form" (ppr e)
-----------------------------------------------------------------------------
-- Building representations of auxillary structures like Match, Clause, Stmt,
-repMatchTup :: LMatch Name (LHsExpr Name) -> DsM (Core TH.MatchQ)
+repMatchTup :: LMatch GhcRn (LHsExpr GhcRn) -> DsM (Core TH.MatchQ)
repMatchTup (L _ (Match _ [p] _ (GRHSs guards (L _ wheres)))) =
do { ss1 <- mkGenSyms (collectPatBinders p)
; addBinds ss1 $ do {
@@ -1296,7 +1299,7 @@ repMatchTup (L _ (Match _ [p] _ (GRHSs guards (L _ wheres)))) =
; wrapGenSyms (ss1++ss2) match }}}
repMatchTup _ = panic "repMatchTup: case alt with more than one arg"
-repClauseTup :: LMatch Name (LHsExpr Name) -> DsM (Core TH.ClauseQ)
+repClauseTup :: LMatch GhcRn (LHsExpr GhcRn) -> DsM (Core TH.ClauseQ)
repClauseTup (L _ (Match _ ps _ (GRHSs guards (L _ wheres)))) =
do { ss1 <- mkGenSyms (collectPatsBinders ps)
; addBinds ss1 $ do {
@@ -1307,7 +1310,7 @@ repClauseTup (L _ (Match _ ps _ (GRHSs guards (L _ wheres)))) =
; clause <- repClause ps1 gs ds
; wrapGenSyms (ss1++ss2) clause }}}
-repGuards :: [LGRHS Name (LHsExpr Name)] -> DsM (Core TH.BodyQ)
+repGuards :: [LGRHS GhcRn (LHsExpr GhcRn)] -> DsM (Core TH.BodyQ)
repGuards [L _ (GRHS [] e)]
= do {a <- repLE e; repNormal a }
repGuards other
@@ -1316,7 +1319,8 @@ repGuards other
; gd <- repGuarded (nonEmptyCoreList ys)
; wrapGenSyms (concat xs) gd }
-repLGRHS :: LGRHS Name (LHsExpr Name) -> DsM ([GenSymBind], (Core (TH.Q (TH.Guard, TH.Exp))))
+repLGRHS :: LGRHS GhcRn (LHsExpr GhcRn)
+ -> DsM ([GenSymBind], (Core (TH.Q (TH.Guard, TH.Exp))))
repLGRHS (L _ (GRHS [L _ (BodyStmt e1 _ _ _)] e2))
= do { guarded <- repLNormalGE e1 e2
; return ([], guarded) }
@@ -1326,19 +1330,20 @@ repLGRHS (L _ (GRHS ss rhs))
; guarded <- repPatGE (nonEmptyCoreList ss') rhs'
; return (gs, guarded) }
-repFields :: HsRecordBinds Name -> DsM (Core [TH.Q TH.FieldExp])
+repFields :: HsRecordBinds GhcRn -> DsM (Core [TH.Q TH.FieldExp])
repFields (HsRecFields { rec_flds = flds })
= repList fieldExpQTyConName rep_fld flds
where
- rep_fld :: LHsRecField Name (LHsExpr Name) -> DsM (Core (TH.Q TH.FieldExp))
+ rep_fld :: LHsRecField GhcRn (LHsExpr GhcRn)
+ -> DsM (Core (TH.Q TH.FieldExp))
rep_fld (L _ fld) = do { fn <- lookupLOcc (hsRecFieldSel fld)
; e <- repLE (hsRecFieldArg fld)
; repFieldExp fn e }
-repUpdFields :: [LHsRecUpdField Name] -> DsM (Core [TH.Q TH.FieldExp])
+repUpdFields :: [LHsRecUpdField GhcRn] -> DsM (Core [TH.Q TH.FieldExp])
repUpdFields = repList fieldExpQTyConName rep_fld
where
- rep_fld :: LHsRecUpdField Name -> DsM (Core (TH.Q TH.FieldExp))
+ rep_fld :: LHsRecUpdField GhcRn -> DsM (Core (TH.Q TH.FieldExp))
rep_fld (L l fld) = case unLoc (hsRecFieldLbl fld) of
Unambiguous _ sel_name -> do { fn <- lookupLOcc (L l sel_name)
; e <- repLE (hsRecFieldArg fld)
@@ -1372,10 +1377,10 @@ repUpdFields = repList fieldExpQTyConName rep_fld
-- The helper function repSts computes the translation of each sub expression
-- and a bunch of prefix bindings denoting the dynamic renaming.
-repLSts :: [LStmt Name (LHsExpr Name)] -> DsM ([GenSymBind], [Core TH.StmtQ])
+repLSts :: [LStmt GhcRn (LHsExpr GhcRn)] -> DsM ([GenSymBind], [Core TH.StmtQ])
repLSts stmts = repSts (map unLoc stmts)
-repSts :: [Stmt Name (LHsExpr Name)] -> DsM ([GenSymBind], [Core TH.StmtQ])
+repSts :: [Stmt GhcRn (LHsExpr GhcRn)] -> DsM ([GenSymBind], [Core TH.StmtQ])
repSts (BindStmt p e _ _ _ : ss) =
do { e2 <- repLE e
; ss1 <- mkGenSyms (collectPatBinders p)
@@ -1402,7 +1407,8 @@ repSts (ParStmt stmt_blocks _ _ _ : ss) =
; (ss2, zs) <- addBinds ss1 (repSts ss)
; return (ss1++ss2, z : zs) }
where
- rep_stmt_block :: ParStmtBlock Name Name -> DsM ([GenSymBind], Core [TH.StmtQ])
+ rep_stmt_block :: ParStmtBlock GhcRn GhcRn
+ -> DsM ([GenSymBind], Core [TH.StmtQ])
rep_stmt_block (ParStmtBlock stmts _ _) =
do { (ss1, zs) <- repSts (map unLoc stmts)
; zs1 <- coreList stmtQTyConName zs
@@ -1419,7 +1425,7 @@ repSts other = notHandled "Exotic statement" (ppr other)
-- Bindings
-----------------------------------------------------------
-repBinds :: HsLocalBinds Name -> DsM ([GenSymBind], Core [TH.DecQ])
+repBinds :: HsLocalBinds GhcRn -> DsM ([GenSymBind], Core [TH.DecQ])
repBinds EmptyLocalBinds
= do { core_list <- coreList decQTyConName []
; return ([], core_list) }
@@ -1439,7 +1445,7 @@ repBinds (HsValBinds decs)
(de_loc (sort_by_loc prs))
; return (ss, core_list) }
-rep_val_binds :: HsValBinds Name -> DsM [(SrcSpan, Core TH.DecQ)]
+rep_val_binds :: HsValBinds GhcRn -> DsM [(SrcSpan, Core TH.DecQ)]
-- Assumes: all the binders of the binding are already in the meta-env
rep_val_binds (ValBindsOut binds sigs)
= do { core1 <- rep_binds' (unionManyBags (map snd binds))
@@ -1448,14 +1454,14 @@ rep_val_binds (ValBindsOut binds sigs)
rep_val_binds (ValBindsIn _ _)
= panic "rep_val_binds: ValBindsIn"
-rep_binds :: LHsBinds Name -> DsM [Core TH.DecQ]
+rep_binds :: LHsBinds GhcRn -> DsM [Core TH.DecQ]
rep_binds binds = do { binds_w_locs <- rep_binds' binds
; return (de_loc (sort_by_loc binds_w_locs)) }
-rep_binds' :: LHsBinds Name -> DsM [(SrcSpan, Core TH.DecQ)]
+rep_binds' :: LHsBinds GhcRn -> DsM [(SrcSpan, Core TH.DecQ)]
rep_binds' = mapM rep_bind . bagToList
-rep_bind :: LHsBind Name -> DsM (SrcSpan, Core TH.DecQ)
+rep_bind :: LHsBind GhcRn -> DsM (SrcSpan, Core TH.DecQ)
-- Assumes: all the binders of the binding are already in the meta-env
-- Note GHC treats declarations of a variable (not a pattern)
@@ -1571,7 +1577,7 @@ repRecordPatSynArgs :: Core [TH.Name]
-> DsM (Core TH.PatSynArgsQ)
repRecordPatSynArgs (MkC sels) = rep2 recordPatSynName [sels]
-repPatSynDir :: HsPatSynDir Name -> DsM (Core TH.PatSynDirQ)
+repPatSynDir :: HsPatSynDir GhcRn -> DsM (Core TH.PatSynDirQ)
repPatSynDir Unidirectional = rep2 unidirPatSynName []
repPatSynDir ImplicitBidirectional = rep2 implBidirPatSynName []
repPatSynDir (ExplicitBidirectional (MG { mg_alts = L _ clauses }))
@@ -1606,7 +1612,7 @@ repExplBidirPatSynDir (MkC cls) = rep2 explBidirPatSynName [cls]
-- Haskell Template's Meta.Exp type so we punt if it isn't a simple thing like
-- (\ p1 .. pn -> exp) by causing an error.
-repLambda :: LMatch Name (LHsExpr Name) -> DsM (Core TH.ExpQ)
+repLambda :: LMatch GhcRn (LHsExpr GhcRn) -> DsM (Core TH.ExpQ)
repLambda (L _ (Match _ ps _ (GRHSs [L _ (GRHS [] e)] (L _ EmptyLocalBinds))))
= do { let bndrs = collectPatsBinders ps ;
; ss <- mkGenSyms bndrs
@@ -1625,13 +1631,13 @@ repLambda (L _ m) = notHandled "Guarded labmdas" (pprMatch m)
-- variable should already appear in the environment.
-- Process a list of patterns
-repLPs :: [LPat Name] -> DsM (Core [TH.PatQ])
+repLPs :: [LPat GhcRn] -> DsM (Core [TH.PatQ])
repLPs ps = repList patQTyConName repLP ps
-repLP :: LPat Name -> DsM (Core TH.PatQ)
+repLP :: LPat GhcRn -> DsM (Core TH.PatQ)
repLP (L _ p) = repP p
-repP :: Pat Name -> DsM (Core TH.PatQ)
+repP :: Pat GhcRn -> DsM (Core TH.PatQ)
repP (WildPat _) = repPwild
repP (LitPat l) = do { l2 <- repLiteral l; repPlit l2 }
repP (VarPat (L _ x)) = do { x' <- lookupBinder x; repPvar x' }
@@ -1656,7 +1662,7 @@ repP (ConPatIn dc details)
repPinfix p1' con_str p2' }
}
where
- rep_fld :: LHsRecField Name (LPat Name) -> DsM (Core (TH.Name,TH.PatQ))
+ rep_fld :: LHsRecField GhcRn (LPat GhcRn) -> DsM (Core (TH.Name,TH.PatQ))
rep_fld (L _ fld) = do { MkC v <- lookupLOcc (hsRecFieldSel fld)
; MkC p <- repLP (hsRecFieldArg fld)
; rep2 fieldPatName [v,p] }
@@ -1977,7 +1983,8 @@ repNormal :: Core TH.ExpQ -> DsM (Core TH.BodyQ)
repNormal (MkC e) = rep2 normalBName [e]
------------ Guards ----
-repLNormalGE :: LHsExpr Name -> LHsExpr Name -> DsM (Core (TH.Q (TH.Guard, TH.Exp)))
+repLNormalGE :: LHsExpr GhcRn -> LHsExpr GhcRn
+ -> DsM (Core (TH.Q (TH.Guard, TH.Exp)))
repLNormalGE g e = do g' <- repLE g
e' <- repLE e
repNormalGE g' e'
@@ -2171,15 +2178,15 @@ repCtxt :: Core [TH.PredQ] -> DsM (Core TH.CxtQ)
repCtxt (MkC tys) = rep2 cxtName [tys]
repDataCon :: Located Name
- -> HsConDeclDetails Name
+ -> HsConDeclDetails GhcRn
-> DsM (Core TH.ConQ)
repDataCon con details
= do con' <- lookupLOcc con -- See Note [Binders and occurrences]
repConstr details Nothing [con']
repGadtDataCons :: [Located Name]
- -> HsConDeclDetails Name
- -> LHsType Name
+ -> HsConDeclDetails GhcRn
+ -> LHsType GhcRn
-> DsM (Core TH.ConQ)
repGadtDataCons cons details res_ty
= do cons' <- mapM lookupLOcc cons -- See Note [Binders and occurrences]
@@ -2190,8 +2197,8 @@ repGadtDataCons cons details res_ty
-- argument is a singleton list
-- * for GADTs data constructors second argument is (Just return_type) and
-- third argument is a non-empty list
-repConstr :: HsConDeclDetails Name
- -> Maybe (LHsType Name)
+repConstr :: HsConDeclDetails GhcRn
+ -> Maybe (LHsType GhcRn)
-> [Core TH.Name]
-> DsM (Core TH.ConQ)
repConstr (PrefixCon ps) Nothing [con]
@@ -2216,7 +2223,7 @@ repConstr (RecCon (L _ ips)) resTy cons
where
rep_ip (L _ ip) = mapM (rep_one_ip (cd_fld_type ip)) (cd_fld_names ip)
- rep_one_ip :: LBangType Name -> LFieldOcc Name -> DsM (Core a)
+ rep_one_ip :: LBangType GhcRn -> LFieldOcc GhcRn -> DsM (Core a)
rep_one_ip t n = do { MkC v <- lookupOcc (selectorFieldOcc $ unLoc n)
; MkC ty <- repBangTy t
; rep2 varBangTypeName [v,ty] }
@@ -2359,7 +2366,7 @@ repTyVarSig (MkC bndr) = rep2 tyVarSigName [bndr]
----------------------------------------------------------
-- Literals
-repLiteral :: HsLit -> DsM (Core TH.Lit)
+repLiteral :: HsLit GhcRn -> DsM (Core TH.Lit)
repLiteral (HsStringPrim _ bs)
= do dflags <- getDynFlags
word8_ty <- lookupType word8TyConName
@@ -2371,9 +2378,9 @@ repLiteral lit
= do lit' <- case lit of
HsIntPrim _ i -> mk_integer i
HsWordPrim _ w -> mk_integer w
- HsInt i -> mk_integer (il_value i)
- HsFloatPrim r -> mk_rational r
- HsDoublePrim r -> mk_rational r
+ HsInt _ i -> mk_integer (il_value i)
+ HsFloatPrim _ r -> mk_rational r
+ HsDoublePrim _ r -> mk_rational r
HsCharPrim _ c -> mk_char c
_ -> return lit
lit_expr <- dsLit lit'
@@ -2383,38 +2390,38 @@ repLiteral lit
where
mb_lit_name = case lit of
HsInteger _ _ _ -> Just integerLName
- HsInt _ -> Just integerLName
+ HsInt _ _ -> Just integerLName
HsIntPrim _ _ -> Just intPrimLName
HsWordPrim _ _ -> Just wordPrimLName
- HsFloatPrim _ -> Just floatPrimLName
- HsDoublePrim _ -> Just doublePrimLName
+ HsFloatPrim _ _ -> Just floatPrimLName
+ HsDoublePrim _ _ -> Just doublePrimLName
HsChar _ _ -> Just charLName
HsCharPrim _ _ -> Just charPrimLName
HsString _ _ -> Just stringLName
- HsRat _ _ -> Just rationalLName
+ HsRat _ _ _ -> Just rationalLName
_ -> Nothing
-mk_integer :: Integer -> DsM HsLit
+mk_integer :: Integer -> DsM (HsLit GhcRn)
mk_integer i = do integer_ty <- lookupType integerTyConName
- return $ HsInteger NoSourceText i integer_ty
+ return $ HsInteger noSourceText i integer_ty
-mk_rational :: FractionalLit -> DsM HsLit
+mk_rational :: FractionalLit -> DsM (HsLit GhcRn)
mk_rational r = do rat_ty <- lookupType rationalTyConName
- return $ HsRat r rat_ty
-mk_string :: FastString -> DsM HsLit
-mk_string s = return $ HsString NoSourceText s
+ return $ HsRat def r rat_ty
+mk_string :: FastString -> DsM (HsLit GhcRn)
+mk_string s = return $ HsString noSourceText s
-mk_char :: Char -> DsM HsLit
-mk_char c = return $ HsChar NoSourceText c
+mk_char :: Char -> DsM (HsLit GhcRn)
+mk_char c = return $ HsChar noSourceText c
-repOverloadedLiteral :: HsOverLit Name -> DsM (Core TH.Lit)
+repOverloadedLiteral :: HsOverLit GhcRn -> DsM (Core TH.Lit)
repOverloadedLiteral (OverLit { ol_val = val})
= do { lit <- mk_lit val; repLiteral lit }
-- The type Rational will be in the environment, because
-- the smart constructor 'TH.Syntax.rationalL' uses it in its type,
-- and rationalL is sucked in when any TH stuff is used
-mk_lit :: OverLitVal -> DsM HsLit
+mk_lit :: OverLitVal -> DsM (HsLit GhcRn)
mk_lit (HsIntegral i) = mk_integer (il_value i)
mk_lit (HsFractional f) = mk_rational f
mk_lit (HsIsString _ s) = mk_string s
@@ -2443,12 +2450,12 @@ repUnboundVar (MkC name) = rep2 unboundVarEName [name]
-- turn a list of patterns into a single pattern matching a list
repList :: Name -> (a -> DsM (Core b))
- -> [a] -> DsM (Core [b])
+ -> [a] -> DsM (Core [b])
repList tc_name f args
= do { args1 <- mapM f args
; coreList tc_name args1 }
-coreList :: Name -- Of the TyCon of the element type
+coreList :: Name -- Of the TyCon of the element type
-> [Core a] -> DsM (Core [a])
coreList tc_name es
= do { elt_ty <- lookupType tc_name; return (coreList' elt_ty es) }
diff --git a/compiler/deSugar/DsMonad.hs b/compiler/deSugar/DsMonad.hs
index 81a8e35d7c..c3a29733be 100644
--- a/compiler/deSugar/DsMonad.hs
+++ b/compiler/deSugar/DsMonad.hs
@@ -105,7 +105,7 @@ instance Outputable DsMatchContext where
ppr (DsMatchContext hs_match ss) = ppr ss <+> pprMatchContext hs_match
data EquationInfo
- = EqnInfo { eqn_pats :: [Pat Id], -- The patterns for an eqn
+ = EqnInfo { eqn_pats :: [Pat GhcTc], -- The patterns for an eqn
eqn_rhs :: MatchResult } -- What to do after match
instance Outputable EquationInfo where
diff --git a/compiler/deSugar/DsUtils.hs b/compiler/deSugar/DsUtils.hs
index db757d6afe..4ef279faed 100644
--- a/compiler/deSugar/DsUtils.hs
+++ b/compiler/deSugar/DsUtils.hs
@@ -92,7 +92,7 @@ hand, which should indeed be bound to the pattern as a whole, then use it;
otherwise, make one up.
-}
-selectSimpleMatchVarL :: LPat Id -> DsM Id
+selectSimpleMatchVarL :: LPat GhcTc -> DsM Id
selectSimpleMatchVarL pat = selectMatchVar (unLoc pat)
-- (selectMatchVars ps tys) chooses variables of type tys
@@ -111,10 +111,10 @@ selectSimpleMatchVarL pat = selectMatchVar (unLoc pat)
-- Then we must not choose (x::Int) as the matching variable!
-- And nowadays we won't, because the (x::Int) will be wrapped in a CoPat
-selectMatchVars :: [Pat Id] -> DsM [Id]
+selectMatchVars :: [Pat GhcTc] -> DsM [Id]
selectMatchVars ps = mapM selectMatchVar ps
-selectMatchVar :: Pat Id -> DsM Id
+selectMatchVar :: Pat GhcTc -> DsM Id
selectMatchVar (BangPat pat) = selectMatchVar (unLoc pat)
selectMatchVar (LazyPat pat) = selectMatchVar (unLoc pat)
selectMatchVar (ParPat pat) = selectMatchVar (unLoc pat)
@@ -174,7 +174,7 @@ The ``equation info'' used by @match@ is relatively complicated and
worthy of a type synonym and a few handy functions.
-}
-firstPat :: EquationInfo -> Pat Id
+firstPat :: EquationInfo -> Pat GhcTc
firstPat eqn = ASSERT( notNull (eqn_pats eqn) ) head (eqn_pats eqn)
shiftEqns :: [EquationInfo] -> [EquationInfo]
@@ -255,7 +255,7 @@ mkGuardedMatchResult pred_expr (MatchResult _ body_fn)
= MatchResult CanFail (\fail -> do body <- body_fn fail
return (mkIfThenElse pred_expr body fail))
-mkCoPrimCaseMatchResult :: Id -- Scrutinee
+mkCoPrimCaseMatchResult :: Id -- Scrutinee
-> Type -- Type of the case
-> [(Literal, MatchResult)] -- Alternatives
-> MatchResult -- Literals are all unlifted
@@ -414,7 +414,8 @@ mkDataConCase var ty alts@(alt1:_) = MatchResult fail_flag mk_case
-- parallel arrays, which are introduced by `tidy1' in the `PArrPat'
-- case
--
-mkPArrCase :: DynFlags -> Id -> Type -> [CaseAlt DataCon] -> CoreExpr -> DsM CoreExpr
+mkPArrCase :: DynFlags -> Id -> Type -> [CaseAlt DataCon] -> CoreExpr
+ -> DsM CoreExpr
mkPArrCase dflags var ty sorted_alts fail = do
lengthP <- dsDPHBuiltin lengthPVar
alt <- unboxAlt
@@ -725,7 +726,7 @@ work out well:
-}
mkSelectorBinds :: [[Tickish Id]] -- ^ ticks to add, possibly
- -> LPat Id -- ^ The pattern
+ -> LPat GhcTc -- ^ The pattern
-> CoreExpr -- ^ Expression to which the pattern is bound
-> DsM (Id,[(Id,CoreExpr)])
-- ^ Id the rhs is bound to, for desugaring strict
@@ -814,31 +815,31 @@ is_triv_pat _ = False
* *
********************************************************************* -}
-mkLHsPatTup :: [LPat Id] -> LPat Id
+mkLHsPatTup :: [LPat GhcTc] -> LPat GhcTc
mkLHsPatTup [] = noLoc $ mkVanillaTuplePat [] Boxed
mkLHsPatTup [lpat] = lpat
mkLHsPatTup lpats = L (getLoc (head lpats)) $
mkVanillaTuplePat lpats Boxed
-mkLHsVarPatTup :: [Id] -> LPat Id
+mkLHsVarPatTup :: [Id] -> LPat GhcTc
mkLHsVarPatTup bs = mkLHsPatTup (map nlVarPat bs)
-mkVanillaTuplePat :: [OutPat Id] -> Boxity -> Pat Id
+mkVanillaTuplePat :: [OutPat GhcTc] -> Boxity -> Pat GhcTc
-- A vanilla tuple pattern simply gets its type from its sub-patterns
mkVanillaTuplePat pats box = TuplePat pats box (map hsLPatType pats)
-- The Big equivalents for the source tuple expressions
-mkBigLHsVarTupId :: [Id] -> LHsExpr Id
+mkBigLHsVarTupId :: [Id] -> LHsExpr GhcTc
mkBigLHsVarTupId ids = mkBigLHsTupId (map nlHsVar ids)
-mkBigLHsTupId :: [LHsExpr Id] -> LHsExpr Id
+mkBigLHsTupId :: [LHsExpr GhcTc] -> LHsExpr GhcTc
mkBigLHsTupId = mkChunkified mkLHsTupleExpr
-- The Big equivalents for the source tuple patterns
-mkBigLHsVarPatTupId :: [Id] -> LPat Id
+mkBigLHsVarPatTupId :: [Id] -> LPat GhcTc
mkBigLHsVarPatTupId bs = mkBigLHsPatTupId (map nlVarPat bs)
-mkBigLHsPatTupId :: [LPat Id] -> LPat Id
+mkBigLHsPatTupId :: [LPat GhcTc] -> LPat GhcTc
mkBigLHsPatTupId = mkChunkified mkLHsPatTup
{-
diff --git a/compiler/deSugar/Match.hs b/compiler/deSugar/Match.hs
index 14166205e2..19f70363d0 100644
--- a/compiler/deSugar/Match.hs
+++ b/compiler/deSugar/Match.hs
@@ -7,6 +7,7 @@ The @match@ function
-}
{-# LANGUAGE CPP #-}
+{-# LANGUAGE TypeFamilies #-}
module Match ( match, matchEquations, matchWrapper, matchSimply, matchSinglePat ) where
@@ -304,12 +305,12 @@ matchOverloadedList (var:vars) ty (eqns@(eqn1:_))
matchOverloadedList _ _ _ = panic "matchOverloadedList"
-- decompose the first pattern and leave the rest alone
-decomposeFirstPat :: (Pat Id -> Pat Id) -> EquationInfo -> EquationInfo
+decomposeFirstPat :: (Pat GhcTc -> Pat GhcTc) -> EquationInfo -> EquationInfo
decomposeFirstPat extractpat (eqn@(EqnInfo { eqn_pats = pat : pats }))
= eqn { eqn_pats = extractpat pat : pats}
decomposeFirstPat _ _ = panic "decomposeFirstPat"
-getCoPat, getBangPat, getViewPat, getOLPat :: Pat Id -> Pat Id
+getCoPat, getBangPat, getViewPat, getOLPat :: Pat GhcTc -> Pat GhcTc
getCoPat (CoPat _ pat _) = pat
getCoPat _ = panic "getCoPat"
getBangPat (BangPat pat ) = unLoc pat
@@ -402,10 +403,10 @@ tidyEqnInfo v eqn@(EqnInfo { eqn_pats = pat : pats })
= do { (wrap, pat') <- tidy1 v pat
; return (wrap, eqn { eqn_pats = do pat' : pats }) }
-tidy1 :: Id -- The Id being scrutinised
- -> Pat Id -- The pattern against which it is to be matched
- -> DsM (DsWrapper, -- Extra bindings to do before the match
- Pat Id) -- Equivalent pattern
+tidy1 :: Id -- The Id being scrutinised
+ -> Pat GhcTc -- The pattern against which it is to be matched
+ -> DsM (DsWrapper, -- Extra bindings to do before the match
+ Pat GhcTc) -- Equivalent pattern
-------------------------------------------------------
-- (pat', mr') = tidy1 v pat mr
@@ -501,7 +502,7 @@ tidy1 _ non_interesting_pat
= return (idDsWrapper, non_interesting_pat)
--------------------
-tidy_bang_pat :: Id -> SrcSpan -> Pat Id -> DsM (DsWrapper, Pat Id)
+tidy_bang_pat :: Id -> SrcSpan -> Pat GhcTc -> DsM (DsWrapper, Pat GhcTc)
-- Discard par/sig under a bang
tidy_bang_pat v _ (ParPat (L l p)) = tidy_bang_pat v l p
@@ -552,7 +553,7 @@ tidy_bang_pat _ l p = return (idDsWrapper, BangPat (L l p))
push_bang_into_newtype_arg :: SrcSpan
-> Type -- The type of the argument we are pushing
-- onto
- -> HsConPatDetails Id -> HsConPatDetails Id
+ -> HsConPatDetails GhcTc -> HsConPatDetails GhcTc
-- See Note [Bang patterns and newtypes]
-- We are transforming !(N p) into (N !p)
push_bang_into_newtype_arg l _ty (PrefixCon (arg:args))
@@ -695,10 +696,10 @@ Call @match@ with all of this information!
\end{enumerate}
-}
-matchWrapper :: HsMatchContext Name -- For shadowing warning messages
- -> Maybe (LHsExpr Id) -- The scrutinee, if we check a case expr
- -> MatchGroup Id (LHsExpr Id) -- Matches being desugared
- -> DsM ([Id], CoreExpr) -- Results
+matchWrapper :: HsMatchContext Name -- For shadowing warning messages
+ -> Maybe (LHsExpr GhcTc) -- The scrutinee, if we check a case expr
+ -> MatchGroup GhcTc (LHsExpr GhcTc) -- Matches being desugared
+ -> DsM ([Id], CoreExpr) -- Results
{-
There is one small problem with the Lambda Patterns, when somebody
@@ -788,7 +789,7 @@ pattern. It returns an expression.
matchSimply :: CoreExpr -- Scrutinee
-> HsMatchContext Name -- Match kind
- -> LPat Id -- Pattern it should match
+ -> LPat GhcTc -- Pattern it should match
-> CoreExpr -- Return this if it matches
-> CoreExpr -- Return this if it doesn't
-> DsM CoreExpr
@@ -801,7 +802,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 Name -> LPat Id
+matchSinglePat :: CoreExpr -> HsMatchContext Name -> LPat GhcTc
-> Type -> MatchResult -> DsM MatchResult
-- matchSinglePat ensures that the scrutinee is a variable
-- and then calls match_single_pat_var
@@ -820,7 +821,7 @@ matchSinglePat scrut hs_ctx pat ty match_result
; return (adjustMatchResult (bindNonRec var scrut) match_result') }
match_single_pat_var :: Id -- See Note [Match Ids]
- -> HsMatchContext Name -> LPat Id
+ -> HsMatchContext Name -> LPat GhcTc
-> Type -> MatchResult -> DsM MatchResult
match_single_pat_var var ctx pat ty match_result
= ASSERT2( isInternalName (idName var), ppr var )
@@ -856,7 +857,7 @@ data PatGroup
| PgBang -- Bang patterns
| PgCo Type -- Coercion patterns; the type is the type
-- of the pattern *inside*
- | PgView (LHsExpr Id) -- view pattern (e -> p):
+ | PgView (LHsExpr GhcTc) -- view pattern (e -> p):
-- the LHsExpr is the expression e
Type -- the Type is the type of p (equivalently, the result type of e)
| PgOverloadedList
@@ -985,14 +986,14 @@ sameGroup _ _ = False
-- NB we can't assume that the two view expressions have the same type. Consider
-- f (e1 -> True) = ...
-- f (e2 -> "hi") = ...
-viewLExprEq :: (LHsExpr Id,Type) -> (LHsExpr Id,Type) -> Bool
+viewLExprEq :: (LHsExpr GhcTc,Type) -> (LHsExpr GhcTc,Type) -> Bool
viewLExprEq (e1,_) (e2,_) = lexp e1 e2
where
- lexp :: LHsExpr Id -> LHsExpr Id -> Bool
+ lexp :: LHsExpr GhcTc -> LHsExpr GhcTc -> Bool
lexp e e' = exp (unLoc e) (unLoc e')
---------
- exp :: HsExpr Id -> HsExpr Id -> Bool
+ exp :: HsExpr GhcTc -> HsExpr GhcTc -> Bool
-- real comparison is on HsExpr's
-- strip parens
exp (HsPar (L _ e)) e' = exp e e'
@@ -1037,7 +1038,7 @@ viewLExprEq (e1,_) (e2,_) = lexp e1 e2
exp _ _ = False
---------
- syn_exp :: SyntaxExpr Id -> SyntaxExpr Id -> Bool
+ syn_exp :: SyntaxExpr GhcTc -> SyntaxExpr GhcTc -> Bool
syn_exp (SyntaxExpr { syn_expr = expr1
, syn_arg_wraps = arg_wraps1
, syn_res_wrap = res_wrap1 })
@@ -1084,7 +1085,7 @@ viewLExprEq (e1,_) (e2,_) = lexp e1 e2
eq_list _ (_:_) [] = False
eq_list eq (x:xs) (y:ys) = eq x y && eq_list eq xs ys
-patGroup :: DynFlags -> Pat Id -> PatGroup
+patGroup :: DynFlags -> Pat GhcTc -> PatGroup
patGroup _ (ConPatOut { pat_con = L _ con
, pat_arg_tys = tys })
| RealDataCon dcon <- con = PgCon dcon
diff --git a/compiler/deSugar/Match.hs-boot b/compiler/deSugar/Match.hs-boot
index 31bd351caa..4096b9cd0b 100644
--- a/compiler/deSugar/Match.hs-boot
+++ b/compiler/deSugar/Match.hs-boot
@@ -5,6 +5,7 @@ import DsMonad ( DsM, EquationInfo, MatchResult )
import CoreSyn ( CoreExpr )
import HsSyn ( LPat, HsMatchContext, MatchGroup, LHsExpr )
import Name ( Name )
+import HsExtension ( GhcTc )
match :: [Id]
-> Type
@@ -13,14 +14,14 @@ match :: [Id]
matchWrapper
:: HsMatchContext Name
- -> Maybe (LHsExpr Id)
- -> MatchGroup Id (LHsExpr Id)
+ -> Maybe (LHsExpr GhcTc)
+ -> MatchGroup GhcTc (LHsExpr GhcTc)
-> DsM ([Id], CoreExpr)
matchSimply
:: CoreExpr
-> HsMatchContext Name
- -> LPat Id
+ -> LPat GhcTc
-> CoreExpr
-> CoreExpr
-> DsM CoreExpr
@@ -28,7 +29,7 @@ matchSimply
matchSinglePat
:: CoreExpr
-> HsMatchContext Name
- -> LPat Id
+ -> LPat GhcTc
-> Type
-> MatchResult
-> DsM MatchResult
diff --git a/compiler/deSugar/MatchCon.hs b/compiler/deSugar/MatchCon.hs
index 47d1276ba6..7923ae4eb5 100644
--- a/compiler/deSugar/MatchCon.hs
+++ b/compiler/deSugar/MatchCon.hs
@@ -7,6 +7,7 @@ Pattern-matching constructors
-}
{-# LANGUAGE CPP #-}
+{-# LANGUAGE TypeFamilies #-}
module MatchCon ( matchConFamily, matchPatSyn ) where
@@ -112,7 +113,7 @@ matchPatSyn (var:vars) ty eqns
_ -> panic "matchPatSyn: not PatSynCon"
matchPatSyn _ _ _ = panic "matchPatSyn []"
-type ConArgPats = HsConDetails (LPat Id) (HsRecFields Id (LPat Id))
+type ConArgPats = HsConDetails (LPat GhcTc) (HsRecFields GhcTc (LPat GhcTc))
matchOneConLike :: [Id]
-> Type
@@ -198,7 +199,8 @@ compatible_pats (RecCon flds1, _) _ = null (rec_flds flds1)
compatible_pats _ (RecCon flds2, _) = null (rec_flds flds2)
compatible_pats _ _ = True -- Prefix or infix con
-same_fields :: HsRecFields Id (LPat Id) -> HsRecFields Id (LPat Id) -> Bool
+same_fields :: HsRecFields GhcTc (LPat GhcTc) -> HsRecFields GhcTc (LPat GhcTc)
+ -> Bool
same_fields flds1 flds2
= all2 (\(L _ f1) (L _ f2)
-> unLoc (hsRecFieldId f1) == unLoc (hsRecFieldId f2))
@@ -215,7 +217,7 @@ conArgPats :: [Type] -- Instantiated argument types
-- Used only to fill in the types of WildPats, which
-- are probably never looked at anyway
-> ConArgPats
- -> [Pat Id]
+ -> [Pat GhcTc]
conArgPats _arg_tys (PrefixCon ps) = map unLoc ps
conArgPats _arg_tys (InfixCon p1 p2) = [unLoc p1, unLoc p2]
conArgPats arg_tys (RecCon (HsRecFields { rec_flds = rpats }))
diff --git a/compiler/deSugar/MatchLit.hs b/compiler/deSugar/MatchLit.hs
index 748de5c8de..c3ba420232 100644
--- a/compiler/deSugar/MatchLit.hs
+++ b/compiler/deSugar/MatchLit.hs
@@ -74,22 +74,22 @@ For numeric literals, we try to detect there use at a standard type
See also below where we look for @DictApps@ for \tr{plusInt}, etc.
-}
-dsLit :: HsLit -> DsM CoreExpr
+dsLit :: HsLit GhcRn -> DsM CoreExpr
dsLit (HsStringPrim _ s) = return (Lit (MachStr s))
dsLit (HsCharPrim _ c) = return (Lit (MachChar c))
dsLit (HsIntPrim _ i) = return (Lit (MachInt i))
dsLit (HsWordPrim _ w) = return (Lit (MachWord w))
dsLit (HsInt64Prim _ i) = return (Lit (MachInt64 i))
dsLit (HsWord64Prim _ w) = return (Lit (MachWord64 w))
-dsLit (HsFloatPrim f) = return (Lit (MachFloat (fl_value f)))
-dsLit (HsDoublePrim d) = return (Lit (MachDouble (fl_value d)))
+dsLit (HsFloatPrim _ f) = return (Lit (MachFloat (fl_value f)))
+dsLit (HsDoublePrim _ d) = return (Lit (MachDouble (fl_value d)))
dsLit (HsChar _ c) = return (mkCharExpr c)
dsLit (HsString _ str) = mkStringExprFS str
dsLit (HsInteger _ i _) = mkIntegerExpr i
-dsLit (HsInt i) = do dflags <- getDynFlags
+dsLit (HsInt _ i) = do dflags <- getDynFlags
return (mkIntExpr dflags (il_value i))
-dsLit (HsRat (FL _ _ val) ty) = do
+dsLit (HsRat _ (FL _ _ val) ty) = do
num <- mkIntegerExpr (numerator val)
denom <- mkIntegerExpr (denominator val)
return (mkCoreConApps ratio_data_con [Type integer_ty, num, denom])
@@ -100,12 +100,12 @@ dsLit (HsRat (FL _ _ val) ty) = do
(head (tyConDataCons tycon), i_ty)
x -> pprPanic "dsLit" (ppr x)
-dsOverLit :: HsOverLit Id -> DsM CoreExpr
+dsOverLit :: HsOverLit GhcTc -> DsM CoreExpr
dsOverLit lit = do { dflags <- getDynFlags
; warnAboutOverflowedLiterals dflags lit
; dsOverLit' dflags lit }
-dsOverLit' :: DynFlags -> HsOverLit Id -> DsM CoreExpr
+dsOverLit' :: DynFlags -> HsOverLit GhcTc -> DsM CoreExpr
-- Post-typechecker, the HsExpr field of an OverLit contains
-- (an expression for) the literal value itself
dsOverLit' dflags (OverLit { ol_val = val, ol_rebindable = rebindable
@@ -153,7 +153,7 @@ conversionNames
-- We can't easily add fromIntegerName, fromRationalName,
-- because they are generated by literals
-warnAboutOverflowedLiterals :: DynFlags -> HsOverLit Id -> DsM ()
+warnAboutOverflowedLiterals :: DynFlags -> HsOverLit GhcTc -> DsM ()
warnAboutOverflowedLiterals dflags lit
| wopt Opt_WarnOverflowedLiterals dflags
, Just (i, tc) <- getIntegralLit lit
@@ -200,7 +200,8 @@ We get an erroneous suggestion for
but perhaps that does not matter too much.
-}
-warnAboutEmptyEnumerations :: DynFlags -> LHsExpr Id -> Maybe (LHsExpr Id) -> LHsExpr Id -> DsM ()
+warnAboutEmptyEnumerations :: DynFlags -> LHsExpr GhcTc -> Maybe (LHsExpr GhcTc)
+ -> LHsExpr GhcTc -> DsM ()
-- Warns about [2,3 .. 1] which returns the empty list
-- Only works for integral types, not floating point
warnAboutEmptyEnumerations dflags fromExpr mThnExpr toExpr
@@ -233,7 +234,7 @@ warnAboutEmptyEnumerations dflags fromExpr mThnExpr toExpr
| otherwise = return ()
-getLHsIntegralLit :: LHsExpr Id -> Maybe (Integer, Name)
+getLHsIntegralLit :: LHsExpr GhcTc -> Maybe (Integer, Name)
-- See if the expression is an Integral literal
-- Remember to look through automatically-added tick-boxes! (Trac #8384)
getLHsIntegralLit (L _ (HsPar e)) = getLHsIntegralLit e
@@ -242,7 +243,7 @@ getLHsIntegralLit (L _ (HsBinTick _ _ e)) = getLHsIntegralLit e
getLHsIntegralLit (L _ (HsOverLit over_lit)) = getIntegralLit over_lit
getLHsIntegralLit _ = Nothing
-getIntegralLit :: HsOverLit Id -> Maybe (Integer, Name)
+getIntegralLit :: HsOverLit GhcTc -> Maybe (Integer, Name)
getIntegralLit (OverLit { ol_val = HsIntegral i, ol_type = ty })
| Just tc <- tyConAppTyCon_maybe ty
= Just (il_value i, tyConName tc)
@@ -256,7 +257,7 @@ getIntegralLit _ = Nothing
************************************************************************
-}
-tidyLitPat :: HsLit -> Pat Id
+tidyLitPat :: HsLit GhcTc -> Pat GhcTc
-- Result has only the following HsLits:
-- HsIntPrim, HsWordPrim, HsCharPrim, HsFloatPrim
-- HsDoublePrim, HsStringPrim, HsString
@@ -273,13 +274,14 @@ tidyLitPat (HsString src s)
tidyLitPat lit = LitPat lit
----------------
-tidyNPat :: (HsLit -> Pat Id) -- How to tidy a LitPat
+tidyNPat :: (HsLit GhcTc -> Pat GhcTc) -- How to tidy a LitPat
-- We need this argument because tidyNPat is called
-- both by Match and by Check, but they tidy LitPats
-- slightly differently; and we must desugar
-- literals consistently (see Trac #5117)
- -> HsOverLit Id -> Maybe (SyntaxExpr Id) -> SyntaxExpr Id -> Type
- -> Pat Id
+ -> HsOverLit GhcTc -> Maybe (SyntaxExpr GhcTc) -> SyntaxExpr GhcTc
+ -> Type
+ -> Pat GhcTc
tidyNPat tidy_lit_pat (OverLit val False _ ty) mb_neg _eq outer_ty
-- False: Take short cuts only if the literal is not using rebindable syntax
--
@@ -308,7 +310,7 @@ tidyNPat tidy_lit_pat (OverLit val False _ ty) mb_neg _eq outer_ty
-- type family Id). In these cases, we can't do the short-cut.
type_change = not (outer_ty `eqType` ty)
- mk_con_pat :: DataCon -> HsLit -> Pat Id
+ mk_con_pat :: DataCon -> HsLit GhcTc -> Pat GhcTc
mk_con_pat con lit = unLoc (mkPrefixConPat con [noLoc $ LitPat lit] [])
mb_int_lit :: Maybe Integer
@@ -375,7 +377,7 @@ matchLiterals (var:vars) ty sub_groups
matchLiterals [] _ _ = panic "matchLiterals []"
---------------------------
-hsLitKey :: DynFlags -> HsLit -> Literal
+hsLitKey :: DynFlags -> HsLit GhcTc -> Literal
-- Get the Core literal corresponding to a HsLit.
-- It only works for primitive types and strings;
-- others have been removed by tidy
@@ -390,8 +392,8 @@ hsLitKey dflags (HsWordPrim _ w) = mkMachWordWrap dflags w
hsLitKey _ (HsInt64Prim _ i) = mkMachInt64Wrap i
hsLitKey _ (HsWord64Prim _ w) = mkMachWord64Wrap w
hsLitKey _ (HsCharPrim _ c) = mkMachChar c
-hsLitKey _ (HsFloatPrim f) = mkMachFloat (fl_value f)
-hsLitKey _ (HsDoublePrim d) = mkMachDouble (fl_value d)
+hsLitKey _ (HsFloatPrim _ f) = mkMachFloat (fl_value f)
+hsLitKey _ (HsDoublePrim _ d) = mkMachDouble (fl_value d)
hsLitKey _ (HsString _ s) = MachStr (fastStringToByteString s)
hsLitKey _ l = pprPanic "hsLitKey" (ppr l)
diff --git a/compiler/deSugar/PmExpr.hs b/compiler/deSugar/PmExpr.hs
index 8c3df9689e..e9af145183 100644
--- a/compiler/deSugar/PmExpr.hs
+++ b/compiler/deSugar/PmExpr.hs
@@ -56,15 +56,15 @@ data PmExpr = PmExprVar Name
| PmExprCon ConLike [PmExpr]
| PmExprLit PmLit
| PmExprEq PmExpr PmExpr -- Syntactic equality
- | PmExprOther (HsExpr Id) -- Note [PmExprOther in PmExpr]
+ | PmExprOther (HsExpr GhcTc) -- Note [PmExprOther in PmExpr]
mkPmExprData :: DataCon -> [PmExpr] -> PmExpr
mkPmExprData dc args = PmExprCon (RealDataCon dc) args
-- | Literals (simple and overloaded ones) for pattern match checking.
-data PmLit = PmSLit HsLit -- simple
- | PmOLit Bool {- is it negated? -} (HsOverLit Id) -- overloaded
+data PmLit = PmSLit (HsLit GhcTc) -- simple
+ | PmOLit Bool {- is it negated? -} (HsOverLit GhcTc) -- overloaded
-- | Equality between literals for pattern match checking.
eqPmLit :: PmLit -> PmLit -> Bool
@@ -229,10 +229,10 @@ substComplexEq x e (ex, ey)
-- -----------------------------------------------------------------------
-- ** Lift source expressions (HsExpr Id) to PmExpr
-lhsExprToPmExpr :: LHsExpr Id -> PmExpr
+lhsExprToPmExpr :: LHsExpr GhcTc -> PmExpr
lhsExprToPmExpr (L _ e) = hsExprToPmExpr e
-hsExprToPmExpr :: HsExpr Id -> PmExpr
+hsExprToPmExpr :: HsExpr GhcTc -> PmExpr
hsExprToPmExpr (HsVar x) = PmExprVar (idName (unLoc x))
hsExprToPmExpr (HsConLikeOut c) = PmExprVar (conLikeName c)
@@ -282,7 +282,7 @@ hsExprToPmExpr (ExprWithTySigOut e _) = lhsExprToPmExpr e
hsExprToPmExpr (HsWrap _ e) = hsExprToPmExpr e
hsExprToPmExpr e = PmExprOther e -- the rest are not handled by the oracle
-synExprToPmExpr :: SyntaxExpr Id -> PmExpr
+synExprToPmExpr :: SyntaxExpr GhcTc -> PmExpr
synExprToPmExpr = hsExprToPmExpr . syn_expr -- ignore the wrappers
{-