diff options
Diffstat (limited to 'compiler/typecheck/TcHsSyn.hs')
-rw-r--r-- | compiler/typecheck/TcHsSyn.hs | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/compiler/typecheck/TcHsSyn.hs b/compiler/typecheck/TcHsSyn.hs index 66fe38ad8f..d7d23a2a81 100644 --- a/compiler/typecheck/TcHsSyn.hs +++ b/compiler/typecheck/TcHsSyn.hs @@ -9,7 +9,7 @@ This module is an extension of @HsSyn@ syntax, for use in the type checker. -} -{-# LANGUAGE CPP #-} +{-# LANGUAGE CPP, TupleSections #-} module TcHsSyn ( mkHsConApp, mkHsDictLet, mkHsApp, @@ -29,7 +29,7 @@ module TcHsSyn ( zonkTopBndrs, zonkTyBndrsX, emptyZonkEnv, mkEmptyZonkEnv, zonkTcTypeToType, zonkTcTypeToTypes, zonkTyVarOcc, - zonkCoToCo + zonkCoToCo, zonkTcKindToKind ) where #include "HsVersions.h" @@ -44,6 +44,7 @@ import TcEvidence import TysPrim import TysWiredIn import Type +import TyCoRep ( TyBinder(..) ) import Coercion import ConLike import DataCon @@ -328,6 +329,15 @@ zonkTyBndrX env tv ; let tv' = mkTyVar (tyVarName tv) ki ; return (extendTyZonkEnv1 env tv', tv') } +zonkTyBinders :: ZonkEnv -> [TcTyBinder] -> TcM (ZonkEnv, [TyBinder]) +zonkTyBinders = mapAccumLM zonkTyBinder + +zonkTyBinder :: ZonkEnv -> TcTyBinder -> TcM (ZonkEnv, TyBinder) +zonkTyBinder env (Anon ty) = (env, ) <$> (Anon <$> zonkTcTypeToType env ty) +zonkTyBinder env (Named tv vis) + = do { (env', tv') <- zonkTyBndrX env tv + ; return (env', Named tv' vis) } + zonkTopExpr :: HsExpr TcId -> TcM (HsExpr Id) zonkTopExpr e = zonkExpr emptyZonkEnv e @@ -1582,6 +1592,14 @@ zonkTcTypeToType = mapType zonk_tycomapper zonkTcTypeToTypes :: ZonkEnv -> [TcType] -> TcM [Type] zonkTcTypeToTypes env tys = mapM (zonkTcTypeToType env) tys +-- | Used during kind-checking in TcTyClsDecls, where it's more convenient +-- to keep the binders and result kind separate. +zonkTcKindToKind :: [TcTyBinder] -> TcKind -> TcM ([TyBinder], Kind) +zonkTcKindToKind binders res_kind + = do { (env, binders') <- zonkTyBinders emptyZonkEnv binders + ; res_kind' <- zonkTcTypeToType env res_kind + ; return (binders', res_kind') } + zonkCoToCo :: ZonkEnv -> Coercion -> TcM Coercion zonkCoToCo = mapCoercion zonk_tycomapper @@ -1604,7 +1622,7 @@ zonkTypeZapping :: UnboundTyVarZonker -- It zaps unbound type variables to (), or some other arbitrary type -- Works on both types and kinds zonkTypeZapping tv - = do { let ty | isLevityVar tv = liftedDataConTy - | otherwise = anyTypeOfKind (tyVarKind tv) + = do { let ty | isRuntimeRepVar tv = ptrRepLiftedTy + | otherwise = anyTypeOfKind (tyVarKind tv) ; writeMetaTyVar tv ty ; return ty } |