diff options
author | Richard Eisenberg <rae@richarde.dev> | 2019-10-03 23:20:13 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-10-16 15:58:58 -0400 |
commit | 51fad9e6693fdf8964d104425122d0010229c939 (patch) | |
tree | 8268d84ed6f18ac3df26e5c7475f2aa9cd54ad54 /compiler/typecheck/TcMType.hs | |
parent | 798037a1f6823c72e3ba59ed726d0ff74d0245e8 (diff) | |
download | haskell-51fad9e6693fdf8964d104425122d0010229c939.tar.gz |
Break up TcRnTypes, among other modules.
This introduces three new modules:
- basicTypes/Predicate.hs describes predicates, moving
this logic out of Type. Predicates don't really exist
in Core, and so don't belong in Type.
- typecheck/TcOrigin.hs describes the origin of constraints
and types. It was easy to remove from other modules and
can often be imported instead of other, scarier modules.
- typecheck/Constraint.hs describes constraints as used in
the solver. It is taken from TcRnTypes.
No work other than module splitting is in this patch.
This is the first step toward homogeneous equality, which will
rely more strongly on predicates. And homogeneous equality is the
next step toward a dependently typed core language.
Diffstat (limited to 'compiler/typecheck/TcMType.hs')
-rw-r--r-- | compiler/typecheck/TcMType.hs | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/compiler/typecheck/TcMType.hs b/compiler/typecheck/TcMType.hs index ebd531ec13..e0dc5bcfa8 100644 --- a/compiler/typecheck/TcMType.hs +++ b/compiler/typecheck/TcMType.hs @@ -48,6 +48,8 @@ module TcMType ( unpackCoercionHole, unpackCoercionHole_maybe, checkCoercionHole, + newImplication, + -------------------------------- -- Instantiation newMetaTyVars, newMetaTyVarX, newMetaTyVarsX, @@ -98,9 +100,12 @@ import TyCon import Coercion import Class import Var +import Predicate +import TcOrigin -- others: import TcRnMonad -- TcType, amongst others +import Constraint import TcEvidence import Id import Name @@ -116,7 +121,9 @@ import FastString import Bag import Pair import UniqSet +import DynFlags import qualified GHC.LanguageExtensions as LangExt +import BasicTypes ( TypeOrKind(..) ) import Control.Monad import Maybes @@ -287,6 +294,22 @@ predTypeOccName ty = case classifyPredType ty of IrredPred {} -> mkVarOccFS (fsLit "irred") ForAllPred {} -> mkVarOccFS (fsLit "df") +-- | Create a new 'Implication' with as many sensible defaults for its fields +-- as possible. Note that the 'ic_tclvl', 'ic_binds', and 'ic_info' fields do +-- /not/ have sensible defaults, so they are initialized with lazy thunks that +-- will 'panic' if forced, so one should take care to initialize these fields +-- after creation. +-- +-- This is monadic to look up the 'TcLclEnv', which is used to initialize +-- 'ic_env', and to set the -Winaccessible-code flag. See +-- Note [Avoid -Winaccessible-code when deriving] in TcInstDcls. +newImplication :: TcM Implication +newImplication + = do env <- getLclEnv + warn_inaccessible <- woptM Opt_WarnInaccessibleCode + return (implicationPrototype { ic_env = env + , ic_warn_inaccessible = warn_inaccessible }) + {- ************************************************************************ * * @@ -2211,10 +2234,10 @@ zonkTidyOrigin env (KindEqOrigin ty1 m_ty2 orig t_or_k) Nothing -> return (env1, Nothing) ; (env3, orig') <- zonkTidyOrigin env2 orig ; return (env3, KindEqOrigin ty1' m_ty2' orig' t_or_k) } -zonkTidyOrigin env (FunDepOrigin1 p1 l1 p2 l2) +zonkTidyOrigin env (FunDepOrigin1 p1 o1 l1 p2 o2 l2) = do { (env1, p1') <- zonkTidyTcType env p1 ; (env2, p2') <- zonkTidyTcType env1 p2 - ; return (env2, FunDepOrigin1 p1' l1 p2' l2) } + ; return (env2, FunDepOrigin1 p1' o1 l1 p2' o2 l2) } zonkTidyOrigin env (FunDepOrigin2 p1 o1 p2 l2) = do { (env1, p1') <- zonkTidyTcType env p1 ; (env2, p2') <- zonkTidyTcType env1 p2 @@ -2257,7 +2280,7 @@ tidySkolemInfo _ info = info tidySigSkol :: TidyEnv -> UserTypeCtxt -> TcType -> [(Name,TcTyVar)] -> SkolemInfo -- We need to take special care when tidying SigSkol --- See Note [SigSkol SkolemInfo] in TcRnTypes +-- See Note [SigSkol SkolemInfo] in Origin tidySigSkol env cx ty tv_prs = SigSkol cx (tidy_ty env ty) tv_prs' where |