From: simonmar Date: Wed, 3 Jan 2001 11:18:53 +0000 (+0000) Subject: [project @ 2001-01-03 11:18:51 by simonmar] X-Git-Tag: Approximately_9120_patches~2985 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=20d387c481324aed48e8469d3fbf0695b3b2e365;p=ghc-hetmet.git [project @ 2001-01-03 11:18:51 by simonmar] s/boxed/lifted/ The typechecker's notion of "boxed" versus "unboxed" kind should really have been "unlifted" versus "lifted" instead. It is illegal to unify an unlifted (but boxed) type with a polymorphic type variable, since an unlifted/boxed type is always assumed to be a pointer to the object itself, never a thunk or indirection. This commit removes isUnboxedType, and renames a bunch of things that were previously boxed/unboxed to unlifted/lifted. --- diff --git a/ghc/compiler/hsSyn/HsTypes.lhs b/ghc/compiler/hsSyn/HsTypes.lhs index 0ea040c..786cc50 100644 --- a/ghc/compiler/hsSyn/HsTypes.lhs +++ b/ghc/compiler/hsSyn/HsTypes.lhs @@ -28,7 +28,7 @@ module HsTypes ( import Class ( FunDep ) import Type ( Type, Kind, PredType(..), ClassContext, - splitSigmaTy, boxedTypeKind + splitSigmaTy, liftedTypeKind ) import TypeRep ( Type(..), TyNote(..) ) -- toHsType sees the representation import TyCon ( isTupleTyCon, tupleTyConBoxity, tyConArity, getSynTyConDefn ) @@ -166,8 +166,8 @@ instance Outputable name => Outputable (HsPred name) where ppr (HsPIParam n ty) = hsep [char '?' <> ppr n, text "::", ppr ty] pprHsTyVarBndr :: Outputable name => name -> Kind -> SDoc -pprHsTyVarBndr name kind | kind == boxedTypeKind = ppr name - | otherwise = hsep [ppr name, dcolon, pprParendKind kind] +pprHsTyVarBndr name kind | kind == liftedTypeKind = ppr name + | otherwise = hsep [ppr name, dcolon, pprParendKind kind] pprHsForAll [] [] = empty pprHsForAll tvs cxt diff --git a/ghc/compiler/prelude/PrelNames.lhs b/ghc/compiler/prelude/PrelNames.lhs index c903b16..37d44a2 100644 --- a/ghc/compiler/prelude/PrelNames.lhs +++ b/ghc/compiler/prelude/PrelNames.lhs @@ -273,8 +273,8 @@ usOnceTyConName = kindQual SLIT(".") usOnceTyConKey usManyTyConName = kindQual SLIT("!") usManyTyConKey superKindName = kindQual SLIT("KX") kindConKey superBoxityName = kindQual SLIT("BX") boxityConKey -boxedConName = kindQual SLIT("*") boxedConKey -unboxedConName = kindQual SLIT("#") unboxedConKey +liftedConName = kindQual SLIT("*") liftedConKey +unliftedConName = kindQual SLIT("#") unliftedConKey openKindConName = kindQual SLIT("?") anyBoxConKey usageKindConName = kindQual SLIT("$") usageConKey typeConName = kindQual SLIT("Type") typeConKey @@ -681,8 +681,8 @@ word16TyConKey = mkPreludeTyConUnique 60 word32TyConKey = mkPreludeTyConUnique 61 word64PrimTyConKey = mkPreludeTyConUnique 62 word64TyConKey = mkPreludeTyConUnique 63 -boxedConKey = mkPreludeTyConUnique 64 -unboxedConKey = mkPreludeTyConUnique 65 +liftedConKey = mkPreludeTyConUnique 64 +unliftedConKey = mkPreludeTyConUnique 65 anyBoxConKey = mkPreludeTyConUnique 66 kindConKey = mkPreludeTyConUnique 67 boxityConKey = mkPreludeTyConUnique 68 diff --git a/ghc/compiler/prelude/TysPrim.lhs b/ghc/compiler/prelude/TysPrim.lhs index 05feb3b..b91ebfa 100644 --- a/ghc/compiler/prelude/TysPrim.lhs +++ b/ghc/compiler/prelude/TysPrim.lhs @@ -53,7 +53,7 @@ import Name ( Name ) import PrimRep ( PrimRep(..), isFollowableRep ) import TyCon ( TyCon, ArgVrcs, mkPrimTyCon ) import Type ( mkTyConApp, mkTyConTy, mkTyVarTys, mkTyVarTy, - unboxedTypeKind, boxedTypeKind, openTypeKind, mkArrowKinds + unliftedTypeKind, liftedTypeKind, openTypeKind, mkArrowKinds ) import Unique ( mkAlphaTyVarUnique ) import PrelNames @@ -103,7 +103,7 @@ primTyCons \begin{code} alphaTyVars :: [TyVar] -alphaTyVars = [ mkSysTyVar u boxedTypeKind +alphaTyVars = [ mkSysTyVar u liftedTypeKind | u <- map mkAlphaTyVarUnique [2..] ] betaTyVars = tail alphaTyVars @@ -115,7 +115,7 @@ alphaTys = mkTyVarTys alphaTyVars (alphaTy:betaTy:gammaTy:deltaTy:_) = alphaTys -- openAlphaTyVar is prepared to be instantiated - -- to a boxed or unboxed type variable. It's used for the + -- to a lifted or unlifted type variable. It's used for the -- result type for "error", so that we can have (error Int# "Help") openAlphaTyVar :: TyVar openAlphaTyVar = mkSysTyVar (mkAlphaTyVarUnique 1) openTypeKind @@ -149,10 +149,9 @@ pcPrimTyCon :: Name -> Int -> ArgVrcs -> PrimRep -> TyCon pcPrimTyCon name arity arg_vrcs rep = the_tycon where - the_tycon = mkPrimTyCon name kind arity arg_vrcs rep - kind = mkArrowKinds (take arity (repeat boxedTypeKind)) result_kind - result_kind | isFollowableRep rep = boxedTypeKind -- Represented by a GC-ish ptr - | otherwise = unboxedTypeKind -- Represented by a non-ptr + the_tycon = mkPrimTyCon name kind arity arg_vrcs rep + kind = mkArrowKinds (take arity (repeat liftedTypeKind)) result_kind + result_kind = unliftedTypeKind -- all primitive types are unlifted charPrimTy = mkTyConTy charPrimTyCon charPrimTyCon = pcPrimTyCon charPrimTyConName 0 [] CharRep @@ -186,7 +185,7 @@ doublePrimTyCon = pcPrimTyCon doublePrimTyConName 0 [] DoubleRep %* * %************************************************************************ -State# is the primitive, unboxed type of states. It has one type parameter, +State# is the primitive, unlifted type of states. It has one type parameter, thus State# RealWorld or @@ -200,14 +199,13 @@ mkStatePrimTy ty = mkTyConApp statePrimTyCon [ty] statePrimTyCon = pcPrimTyCon statePrimTyConName 1 vrcsZ VoidRep \end{code} -@_RealWorld@ is deeply magical. It {\em is primitive}, but it -{\em is not unboxed} (hence PtrRep). -We never manipulate values of type RealWorld; it's only used in the type -system, to parameterise State#. +RealWorld is deeply magical. It is *primitive*, but it is not +*unlifted* (hence PrimPtrRep). We never manipulate values of type +RealWorld; it's only used in the type system, to parameterise State#. \begin{code} +realWorldTyCon = mkPrimTyCon realWorldTyConName liftedTypeKind 0 [] PrimPtrRep realWorldTy = mkTyConTy realWorldTyCon -realWorldTyCon = pcPrimTyCon realWorldTyConName 0 [] PrimPtrRep realWorldStatePrimTy = mkStatePrimTy realWorldTy -- State# RealWorld \end{code} @@ -356,17 +354,17 @@ PrimRep (see PrimRep.lhs). The following function returns the primitive TyCon for a given PrimRep. \begin{code} -primRepTyCon CharRep = charPrimTyCon -primRepTyCon Int8Rep = charPrimTyCon -primRepTyCon IntRep = intPrimTyCon -primRepTyCon WordRep = wordPrimTyCon -primRepTyCon Int64Rep = int64PrimTyCon -primRepTyCon Word64Rep = word64PrimTyCon -primRepTyCon AddrRep = addrPrimTyCon -primRepTyCon FloatRep = floatPrimTyCon -primRepTyCon DoubleRep = doublePrimTyCon +primRepTyCon CharRep = charPrimTyCon +primRepTyCon Int8Rep = charPrimTyCon +primRepTyCon IntRep = intPrimTyCon +primRepTyCon WordRep = wordPrimTyCon +primRepTyCon Int64Rep = int64PrimTyCon +primRepTyCon Word64Rep = word64PrimTyCon +primRepTyCon AddrRep = addrPrimTyCon +primRepTyCon FloatRep = floatPrimTyCon +primRepTyCon DoubleRep = doublePrimTyCon primRepTyCon StablePtrRep = stablePtrPrimTyCon primRepTyCon ForeignObjRep = foreignObjPrimTyCon -primRepTyCon WeakPtrRep = weakPrimTyCon -primRepTyCon other = pprPanic "primRepTyCon" (ppr other) +primRepTyCon WeakPtrRep = weakPrimTyCon +primRepTyCon other = pprPanic "primRepTyCon" (ppr other) \end{code} diff --git a/ghc/compiler/prelude/TysWiredIn.lhs b/ghc/compiler/prelude/TysWiredIn.lhs index bed62c4..a4b33c8 100644 --- a/ghc/compiler/prelude/TysWiredIn.lhs +++ b/ghc/compiler/prelude/TysWiredIn.lhs @@ -105,7 +105,7 @@ import TyCon ( TyCon, AlgTyConFlavour(..), tyConDataCons, import BasicTypes ( Arity, RecFlag(..), Boxity(..), isBoxed ) import Type ( Type, mkTyConTy, mkTyConApp, mkTyVarTys, - mkArrowKinds, boxedTypeKind, unboxedTypeKind, + mkArrowKinds, liftedTypeKind, unliftedTypeKind, splitTyConApp_maybe, repType, TauType, ClassContext ) import Unique ( incrUnique, mkTupleTyConUnique, mkTupleDataConUnique ) @@ -175,7 +175,7 @@ pcTyCon new_or_data is_rec name tyvars argvrcs cons gen_info mod = nameModule name - kind = mkArrowKinds (map tyVarKind tyvars) boxedTypeKind + kind = mkArrowKinds (map tyVarKind tyvars) liftedTypeKind gen_info = mk_tc_gen_info mod (nameUnique name) name tycon -- We generate names for the generic to/from Ids by incrementing @@ -245,8 +245,8 @@ mk_tuple boxity arity = (tycon, tuple_con) tycon = mkTupleTyCon tc_name tc_kind arity tyvars tuple_con boxity gen_info tc_name = mkWiredInName mod (mkOccFS tcName name_str) tc_uniq tc_kind = mkArrowKinds (map tyVarKind tyvars) res_kind - res_kind | isBoxed boxity = boxedTypeKind - | otherwise = unboxedTypeKind + res_kind | isBoxed boxity = liftedTypeKind + | otherwise = unliftedTypeKind tyvars | isBoxed boxity = take arity alphaTyVars | otherwise = take arity openAlphaTyVars @@ -285,7 +285,7 @@ unboxedPairDataCon = tupleCon Unboxed 2 -- -- data Void = -- No constructors! -- --- ) It's boxed; there is only one value of this +-- ) It's lifted; there is only one value of this -- type, namely "void", whose semantics is just bottom. -- -- Haskell 98 drops the definition of a Void type, so we just 'simulate' diff --git a/ghc/compiler/rename/ParseIface.y b/ghc/compiler/rename/ParseIface.y index f2882c3..3d7af50 100644 --- a/ghc/compiler/rename/ParseIface.y +++ b/ghc/compiler/rename/ParseIface.y @@ -43,7 +43,7 @@ import BasicTypes ( Fixity(..), FixityDirection(..), ) import CostCentre ( CostCentre(..), IsCafCC(..), IsDupdCC(..) ) import CallConv ( cCallConv ) -import Type ( Kind, mkArrowKind, boxedTypeKind, openTypeKind, usageTypeKind ) +import Type ( Kind, mkArrowKind, liftedTypeKind, openTypeKind, usageTypeKind ) import IdInfo ( exactArity, InlinePragInfo(..) ) import PrimOp ( CCall(..), CCallTarget(..) ) import Lex @@ -693,7 +693,7 @@ tv_name :: { RdrName } tv_bndr :: { HsTyVarBndr RdrName } : tv_name '::' akind { IfaceTyVar $1 $3 } - | tv_name { IfaceTyVar $1 boxedTypeKind } + | tv_name { IfaceTyVar $1 liftedTypeKind } tv_bndrs :: { [HsTyVarBndr RdrName] } : tv_bndrs1 { $1 } @@ -726,7 +726,7 @@ kind :: { Kind } akind :: { Kind } : VARSYM { if $1 == SLIT("*") then - boxedTypeKind + liftedTypeKind else if $1 == SLIT("?") then openTypeKind else if $1 == SLIT("\36") then @@ -895,7 +895,7 @@ core_val_bndr : var_name '::' atype { UfValBinder $1 $3 } core_tv_bndr :: { UfBinder RdrName } core_tv_bndr : '@' tv_name '::' akind { UfTyBinder $2 $4 } - | '@' tv_name { UfTyBinder $2 boxedTypeKind } + | '@' tv_name { UfTyBinder $2 liftedTypeKind } ccall_string :: { FAST_STRING } : STRING { $1 } diff --git a/ghc/compiler/typecheck/TcBinds.lhs b/ghc/compiler/typecheck/TcBinds.lhs index a11484e..4f81c0d 100644 --- a/ghc/compiler/typecheck/TcBinds.lhs +++ b/ghc/compiler/typecheck/TcBinds.lhs @@ -50,7 +50,7 @@ import NameSet import Type ( mkTyVarTy, tyVarsOfTypes, mkTyConApp, mkForAllTys, mkFunTys, mkPredTy, mkForAllTy, isUnLiftedType, - isUnboxedType, unboxedTypeKind, boxedTypeKind, openTypeKind + unliftedTypeKind, liftedTypeKind, openTypeKind ) import FunDeps ( oclose ) import Var ( tyVarKind ) @@ -142,7 +142,7 @@ tc_binds_and_then top_lvl combiner (MonoBind bind sigs is_rec) do_next -- Create specialisations of functions bound here -- We want to keep non-recursive things non-recursive - -- so that we desugar unboxed bindings correctly + -- so that we desugar unlifted bindings correctly case (top_lvl, is_rec) of -- For the top level don't bother will all this bindInstsOfLocalFuns stuff @@ -240,7 +240,7 @@ tcBindWithSigs top_lvl mbind tc_ty_sigs inline_sigs is_rec -- If typechecking the binds fails, then return with each -- signature-less binder given type (forall a.a), to minimise subsequent -- error messages - newTyVar boxedTypeKind `thenNF_Tc` \ alpha_tv -> + newTyVar liftedTypeKind `thenNF_Tc` \ alpha_tv -> let forall_a_a = mkForAllTy alpha_tv (mkTyVarTy alpha_tv) binder_names = collectMonoBinders mbind @@ -281,7 +281,7 @@ tcBindWithSigs top_lvl mbind tc_ty_sigs inline_sigs is_rec getTyVarsToGen is_unrestricted mono_id_tys lie_req `thenNF_Tc` \ (tyvars_not_to_gen, tyvars_to_gen) -> -- Finally, zonk the generalised type variables to real TyVars - -- This commits any unbound kind variables to boxed kind + -- This commits any unbound kind variables to lifted kind -- I'm a little worried that such a kind variable might be -- free in the environment, but I don't think it's possible for -- this to happen when the type variable is not free in the envt @@ -362,10 +362,10 @@ tcBindWithSigs top_lvl mbind tc_ty_sigs inline_sigs is_rec returnTc () ) `thenTc_` - ASSERT( not (any ((== unboxedTypeKind) . tyVarKind) real_tyvars_to_gen_list) ) + ASSERT( not (any ((== unliftedTypeKind) . tyVarKind) real_tyvars_to_gen_list) ) -- The instCantBeGeneralised stuff in tcSimplify should have -- already raised an error if we're trying to generalise an - -- unboxed tyvar (NB: unboxed tyvars are always introduced + -- unlifted tyvar (NB: unlifted tyvars are always introduced -- along with a class constraint) and it's better done there -- because we have more precise origin information. -- That's why we just use an ASSERT here. @@ -410,10 +410,10 @@ tcBindWithSigs top_lvl mbind tc_ty_sigs inline_sigs is_rec pat_binders :: [Name] pat_binders = collectMonoBinders (justPatBindings mbind EmptyMonoBinds) in - -- CHECK FOR UNBOXED BINDERS IN PATTERN BINDINGS + -- CHECK FOR UNLIFTED BINDERS IN PATTERN BINDINGS mapTc (\id -> checkTc (not (idName id `elem` pat_binders - && isUnboxedType (idType id))) - (unboxedPatBindErr id)) zonked_mono_ids + && isUnLiftedType (idType id))) + (unliftedPatBindErr id)) zonked_mono_ids `thenTc_` -- BUILD RESULTS @@ -723,8 +723,8 @@ tcMonoBinds mbinds tc_ty_sigs is_rec -- Figure out the appropriate kind for the pattern, -- and generate a suitable type variable kind = case is_rec of - Recursive -> boxedTypeKind -- Recursive, so no unboxed types - NonRecursive -> openTypeKind -- Non-recursive, so we permit unboxed types + Recursive -> liftedTypeKind -- Recursive, so no unlifted types + NonRecursive -> openTypeKind -- Non-recursive, so we permit unlifted types \end{code} %************************************************************************ @@ -748,7 +748,7 @@ checkSigMatch top_lvl binder_names mono_ids sigs = -- First unify the main_id with IO t, for any old t tcSetErrCtxt mainTyCheckCtxt ( tcLookupTyCon ioTyConName `thenTc` \ ioTyCon -> - newTyVarTy boxedTypeKind `thenNF_Tc` \ t_tv -> + newTyVarTy liftedTypeKind `thenNF_Tc` \ t_tv -> unifyTauTy ((mkTyConApp ioTyCon [t_tv])) (idType main_mono_id) ) `thenTc_` @@ -915,8 +915,8 @@ valSpecSigCtxt v ty nest 4 (ppr v <+> dcolon <+> ppr ty)] ----------------------------------------------- -unboxedPatBindErr id - = ptext SLIT("variable in a lazy pattern binding has unboxed type: ") +unliftedPatBindErr id + = ptext SLIT("variable in a lazy pattern binding has unlifted type: ") <+> quotes (ppr id) ----------------------------------------------- diff --git a/ghc/compiler/typecheck/TcDeriv.lhs b/ghc/compiler/typecheck/TcDeriv.lhs index db21e8e..cca7316 100644 --- a/ghc/compiler/typecheck/TcDeriv.lhs +++ b/ghc/compiler/typecheck/TcDeriv.lhs @@ -44,7 +44,8 @@ import TyCon ( tyConTyVars, tyConDataCons, tyConTheta, maybeTyConSingleCon, isDataTyCon, isEnumerationTyCon, TyCon ) -import Type ( TauType, PredType(..), mkTyVarTys, mkTyConApp, isUnboxedType ) +import Type ( TauType, PredType(..), mkTyVarTys, mkTyConApp, + isUnLiftedType ) import Var ( TyVar ) import PrelNames import Util ( zipWithEqual, sortLt ) @@ -317,7 +318,7 @@ makeDerivEqns tycl_decls mk_constraints data_con = [ (clas, [arg_ty]) | arg_ty <- dataConArgTys data_con tyvar_tys, - not (isUnboxedType arg_ty) -- No constraints for unboxed types? + not (isUnLiftedType arg_ty) -- No constraints for unlifted types? ] in case chk_out clas tycon of @@ -537,7 +538,7 @@ data Foo ... = ... con2tag_Foo :: Foo ... -> Int# tag2con_Foo :: Int -> Foo ... -- easier if Int, not Int# -maxtag_Foo :: Int -- ditto (NB: not unboxed) +maxtag_Foo :: Int -- ditto (NB: not unlifted) We have a @con2tag@ function for a tycon if: diff --git a/ghc/compiler/typecheck/TcExpr.lhs b/ghc/compiler/typecheck/TcExpr.lhs index 65c328c..536a5d3 100644 --- a/ghc/compiler/typecheck/TcExpr.lhs +++ b/ghc/compiler/typecheck/TcExpr.lhs @@ -52,7 +52,7 @@ import Type ( mkFunTy, mkAppTy, mkTyVarTys, ipName_maybe, splitRhoTy, isTauTy, tyVarsOfType, tyVarsOfTypes, isSigmaTy, splitAlgTyConApp, splitAlgTyConApp_maybe, - boxedTypeKind, openTypeKind, mkArrowKind, + liftedTypeKind, openTypeKind, mkArrowKind, tidyOpenType ) import TyCon ( TyCon, tyConTyVars ) @@ -293,10 +293,10 @@ tcMonoExpr (HsCCall lbl args may_gc is_asm ignored_fake_result_ty) res_ty newTyVarTys (length tv_idxs) openTypeKind `thenNF_Tc` \ arg_tys -> tcMonoExprs args arg_tys `thenTc` \ (args', args_lie) -> - -- The argument types can be unboxed or boxed; the result - -- type must, however, be boxed since it's an argument to the IO + -- The argument types can be unlifted or lifted; the result + -- type must, however, be lifted since it's an argument to the IO -- type constructor. - newTyVarTy boxedTypeKind `thenNF_Tc` \ result_ty -> + newTyVarTy liftedTypeKind `thenNF_Tc` \ result_ty -> let io_result_ty = mkTyConApp ioTyCon [result_ty] in @@ -519,7 +519,7 @@ tcMonoExpr expr@(RecordUpd record_expr rbinds) res_ty mk_inst_ty (tyvar, result_inst_ty) | tyvar `elemVarSet` common_tyvars = returnNF_Tc result_inst_ty -- Same as result type - | otherwise = newTyVarTy boxedTypeKind -- Fresh type + | otherwise = newTyVarTy liftedTypeKind -- Fresh type in mapNF_Tc mk_inst_ty (zip con_tyvars result_inst_tys) `thenNF_Tc` \ inst_tys -> @@ -839,8 +839,8 @@ tcDoStmts do_or_lc stmts src_loc res_ty ASSERT( not (null stmts) ) tcAddSrcLoc src_loc $ - newTyVarTy (mkArrowKind boxedTypeKind boxedTypeKind) `thenNF_Tc` \ m -> - newTyVarTy boxedTypeKind `thenNF_Tc` \ elt_ty -> + newTyVarTy (mkArrowKind liftedTypeKind liftedTypeKind) `thenNF_Tc` \ m -> + newTyVarTy liftedTypeKind `thenNF_Tc` \ elt_ty -> unifyTauTy res_ty (mkAppTy m elt_ty) `thenTc_` -- If it's a comprehension we're dealing with, diff --git a/ghc/compiler/typecheck/TcForeign.lhs b/ghc/compiler/typecheck/TcForeign.lhs index c8d61d2..8208083 100644 --- a/ghc/compiler/typecheck/TcForeign.lhs +++ b/ghc/compiler/typecheck/TcForeign.lhs @@ -27,7 +27,7 @@ import RnHsSyn ( RenamedHsDecl, RenamedForeignDecl ) import TcMonad import TcEnv ( newLocalId ) -import TcMonoType ( tcHsBoxedSigType ) +import TcMonoType ( tcHsLiftedSigType ) import TcHsSyn ( TcMonoBinds, TypecheckedForeignDecl, TcForeignExportDecl ) import TcExpr ( tcPolyExpr ) @@ -84,7 +84,7 @@ tcFImport :: RenamedForeignDecl -> TcM (Id, TypecheckedForeignDecl) tcFImport fo@(ForeignDecl nm FoExport hs_ty Dynamic cconv src_loc) = tcAddSrcLoc src_loc $ tcAddErrCtxt (foreignDeclCtxt fo) $ - tcHsBoxedSigType hs_ty `thenTc` \ sig_ty -> + tcHsLiftedSigType hs_ty `thenTc` \ sig_ty -> let -- drop the foralls before inspecting the structure -- of the foreign type. @@ -99,7 +99,7 @@ tcFImport fo@(ForeignDecl nm FoExport hs_ty Dynamic cconv src_loc) = tcFImport fo@(ForeignDecl nm FoLabel hs_ty ext_nm cconv src_loc) = tcAddSrcLoc src_loc $ tcAddErrCtxt (foreignDeclCtxt fo) $ - tcHsBoxedSigType hs_ty `thenTc` \ sig_ty -> + tcHsLiftedSigType hs_ty `thenTc` \ sig_ty -> let -- drop the foralls before inspecting the structure -- of the foreign type. @@ -114,7 +114,7 @@ tcFImport fo@(ForeignDecl nm imp_exp@(FoImport isUnsafe) hs_ty ext_nm cconv src_ tcAddSrcLoc src_loc $ tcAddErrCtxt (foreignDeclCtxt fo) $ - tcHsBoxedSigType hs_ty `thenTc` \ ty -> + tcHsLiftedSigType hs_ty `thenTc` \ ty -> -- Check that the type has the right shape -- and that the argument and result types are acceptable. let @@ -133,7 +133,7 @@ tcFExport fo@(ForeignDecl nm imp_exp hs_ty ext_nm cconv src_loc) = tcAddSrcLoc src_loc $ tcAddErrCtxt (foreignDeclCtxt fo) $ - tcHsBoxedSigType hs_ty `thenTc` \ sig_ty -> + tcHsLiftedSigType hs_ty `thenTc` \ sig_ty -> tcPolyExpr (HsVar nm) sig_ty `thenTc` \ (rhs, lie, _, _, _) -> let diff --git a/ghc/compiler/typecheck/TcGenDeriv.lhs b/ghc/compiler/typecheck/TcGenDeriv.lhs index 758dbaa..96ac572 100644 --- a/ghc/compiler/typecheck/TcGenDeriv.lhs +++ b/ghc/compiler/typecheck/TcGenDeriv.lhs @@ -53,7 +53,7 @@ import SrcLoc ( generatedSrcLoc, SrcLoc ) import TyCon ( TyCon, isNewTyCon, tyConDataCons, isEnumerationTyCon, maybeTyConSingleCon, tyConFamilySize ) -import Type ( isUnLiftedType, isUnboxedType, Type ) +import Type ( isUnLiftedType, Type ) import TysPrim ( charPrimTy, intPrimTy, wordPrimTy, addrPrimTy, floatPrimTy, doublePrimTy ) @@ -103,7 +103,7 @@ data Foo ... = N1 | N2 ... | Nn | O1 a b | O2 Int | O3 Double b b | ... (==) (O3 a1 b1 c1) (O3 a2 b2 c2) = a1 == a2 && b1 == b2 && c1 == c2 \end{verbatim} - Note: if we're comparing unboxed things, e.g., if \tr{a1} and + Note: if we're comparing unlifted things, e.g., if \tr{a1} and \tr{a2} are \tr{Float#}s, then we have to generate \begin{verbatim} case (a1 `eqFloat#` a2) of @@ -288,7 +288,7 @@ cmp_eq (O3 a1 b1 c1) (O3 a2 b2 c2) } \end{verbatim} - Again, we must be careful about unboxed comparisons. For example, + Again, we must be careful about unlifted comparisons. For example, if \tr{a1} and \tr{a2} were \tr{Int#}s in the 2nd example above, we'd need to generate: @@ -621,7 +621,7 @@ instance ... Ix (Foo ...) where False }}} \end{verbatim} -(modulo suitable case-ification to handle the unboxed tags) +(modulo suitable case-ification to handle the unlifted tags) For a single-constructor type (NB: this includes all tuples), e.g., \begin{verbatim} @@ -1088,7 +1088,7 @@ data Foo ... = ... con2tag_Foo :: Foo ... -> Int# tag2con_Foo :: Int -> Foo ... -- easier if Int, not Int# -maxtag_Foo :: Int -- ditto (NB: not unboxed) +maxtag_Foo :: Int -- ditto (NB: not unlifted) \end{verbatim} The `tags' here start at zero, hence the @fIRST_TAG@ (currently one) @@ -1223,7 +1223,7 @@ compare_gen_Case fun lt eq gt a b generatedSrcLoc careful_compare_Case ty lt eq gt a b - = if not (isUnboxedType ty) then + = if not (isUnLiftedType ty) then compare_gen_Case compare_RDR lt eq gt a b else -- we have to do something special for primitive things... @@ -1270,7 +1270,7 @@ append_Expr a b = genOpApp a append_RDR b eq_Expr :: Type -> RdrNameHsExpr -> RdrNameHsExpr -> RdrNameHsExpr eq_Expr ty a b - = if not (isUnboxedType ty) then + = if not (isUnLiftedType ty) then genOpApp a eq_RDR b else -- we have to do something special for primitive things... genOpApp a relevant_eq_op b diff --git a/ghc/compiler/typecheck/TcMatches.lhs b/ghc/compiler/typecheck/TcMatches.lhs index 7fa3790..87644fa 100644 --- a/ghc/compiler/typecheck/TcMatches.lhs +++ b/ghc/compiler/typecheck/TcMatches.lhs @@ -32,7 +32,7 @@ import TysWiredIn ( boolTy ) import BasicTypes ( RecFlag(..) ) import Type ( tyVarsOfType, isTauTy, mkArrowKind, mkAppTy, mkFunTy, - boxedTypeKind, openTypeKind ) + liftedTypeKind, openTypeKind ) import SrcLoc ( SrcLoc ) import VarSet import Var ( Id ) @@ -269,8 +269,8 @@ tcMatchPats (pat:pats) expected_ty \begin{code} tcParStep src_loc stmts - = newTyVarTy (mkArrowKind boxedTypeKind boxedTypeKind) `thenTc` \ m -> - newTyVarTy boxedTypeKind `thenTc` \ elt_ty -> + = newTyVarTy (mkArrowKind liftedTypeKind liftedTypeKind) `thenTc` \ m -> + newTyVarTy liftedTypeKind `thenTc` \ elt_ty -> unifyListTy (mkAppTy m elt_ty) `thenTc_` tcStmts ListComp (mkAppTy m) elt_ty src_loc stmts `thenTc` \ ((stmts', val_env), stmts_lie) -> @@ -333,7 +333,7 @@ tcStmts do_or_lc m elt_ty loc (stmt@(GuardStmt exp src_loc) : stmts) tcStmts do_or_lc m elt_ty loc (stmt@(BindStmt pat exp src_loc) : stmts) = tcAddSrcLoc src_loc ( tcSetErrCtxt (stmtCtxt do_or_lc stmt) $ - newTyVarTy boxedTypeKind `thenNF_Tc` \ pat_ty -> + newTyVarTy liftedTypeKind `thenNF_Tc` \ pat_ty -> tcPat tcPatBndr_NoSigs pat pat_ty `thenTc` \ (pat', pat_lie, pat_tvs, pat_ids, avail) -> tcExpr exp (m pat_ty) `thenTc` \ (exp', exp_lie) -> returnTc (pat', exp', diff --git a/ghc/compiler/typecheck/TcMonoType.lhs b/ghc/compiler/typecheck/TcMonoType.lhs index e8b2335..0d27127 100644 --- a/ghc/compiler/typecheck/TcMonoType.lhs +++ b/ghc/compiler/typecheck/TcMonoType.lhs @@ -5,12 +5,12 @@ \begin{code} module TcMonoType ( tcHsType, tcHsRecType, - tcHsSigType, tcHsBoxedSigType, + tcHsSigType, tcHsLiftedSigType, tcRecClassContext, checkAmbiguity, -- Kind checking kcHsTyVar, kcHsTyVars, mkTyClTyVars, - kcHsType, kcHsSigType, kcHsBoxedSigType, kcHsContext, + kcHsType, kcHsSigType, kcHsLiftedSigType, kcHsContext, tcTyVars, tcHsTyVars, mkImmutTyVars, TcSigInfo(..), tcTySig, mkTcSig, maybeSig, @@ -42,7 +42,7 @@ import Type ( Type, Kind, PredType(..), ThetaType, SigmaType, TauType, zipFunTys, hoistForAllTys, mkSigmaTy, mkPredTy, mkTyConApp, mkAppTys, splitForAllTys, splitRhoTy, mkRhoTy, - boxedTypeKind, unboxedTypeKind, mkArrowKind, + liftedTypeKind, unliftedTypeKind, mkArrowKind, mkArrowKinds, getTyVar_maybe, getTyVar, splitFunTy_maybe, tidyOpenType, tidyOpenTypes, tidyTyVar, tidyTyVars, tyVarsOfType, tyVarsOfPred, mkForAllTys, @@ -161,45 +161,45 @@ newNamedKindVar name = newKindVar `thenNF_Tc` \ kind -> returnNF_Tc (name, kind) --------------------------- -kcBoxedType :: RenamedHsType -> TcM () - -- The type ty must be a *boxed* *type* -kcBoxedType ty +kcLiftedType :: RenamedHsType -> TcM () + -- The type ty must be a *lifted* *type* +kcLiftedType ty = kcHsType ty `thenTc` \ kind -> tcAddErrCtxt (typeKindCtxt ty) $ - unifyKind boxedTypeKind kind + unifyKind liftedTypeKind kind --------------------------- kcTypeType :: RenamedHsType -> TcM () - -- The type ty must be a *type*, but it can be boxed or unboxed. + -- The type ty must be a *type*, but it can be lifted or unlifted. kcTypeType ty = kcHsType ty `thenTc` \ kind -> tcAddErrCtxt (typeKindCtxt ty) $ unifyOpenTypeKind kind --------------------------- -kcHsSigType, kcHsBoxedSigType :: RenamedHsType -> TcM () +kcHsSigType, kcHsLiftedSigType :: RenamedHsType -> TcM () -- Used for type signatures kcHsSigType = kcTypeType -kcHsBoxedSigType = kcBoxedType +kcHsLiftedSigType = kcLiftedType --------------------------- kcHsType :: RenamedHsType -> TcM TcKind kcHsType (HsTyVar name) = kcTyVar name kcHsType (HsListTy ty) - = kcBoxedType ty `thenTc` \ tau_ty -> - returnTc boxedTypeKind + = kcLiftedType ty `thenTc` \ tau_ty -> + returnTc liftedTypeKind kcHsType (HsTupleTy (HsTupCon _ boxity _) tys) = mapTc kcTypeType tys `thenTc_` returnTc (case boxity of - Boxed -> boxedTypeKind - Unboxed -> unboxedTypeKind) + Boxed -> liftedTypeKind + Unboxed -> unliftedTypeKind) kcHsType (HsFunTy ty1 ty2) = kcTypeType ty1 `thenTc_` kcTypeType ty2 `thenTc_` - returnTc boxedTypeKind + returnTc liftedTypeKind kcHsType ty@(HsOpTy ty1 op ty2) = kcTyVar op `thenTc` \ op_kind -> @@ -211,7 +211,7 @@ kcHsType ty@(HsOpTy ty1 op ty2) kcHsType (HsPredTy pred) = kcHsPred pred `thenTc_` - returnTc boxedTypeKind + returnTc liftedTypeKind kcHsType ty@(HsAppTy ty1 ty2) = kcHsType ty1 `thenTc` \ tc_kind -> @@ -224,7 +224,7 @@ kcHsType (HsForAllTy (Just tv_names) context ty) tcExtendKindEnv kind_env $ kcHsContext context `thenTc_` kcHsType ty `thenTc_` - returnTc boxedTypeKind + returnTc liftedTypeKind --------------------------- kcAppKind fun_kind arg_kind @@ -244,13 +244,13 @@ kcHsContext ctxt = mapTc_ kcHsPred ctxt kcHsPred :: RenamedHsPred -> TcM () kcHsPred pred@(HsPIParam name ty) = tcAddErrCtxt (appKindCtxt (ppr pred)) $ - kcBoxedType ty + kcLiftedType ty kcHsPred pred@(HsPClass cls tys) = tcAddErrCtxt (appKindCtxt (ppr pred)) $ kcClass cls `thenTc` \ kind -> mapTc kcHsType tys `thenTc` \ arg_kinds -> - unifyKind kind (mkArrowKinds arg_kinds boxedTypeKind) + unifyKind kind (mkArrowKinds arg_kinds liftedTypeKind) --------------------------- kcTyVar name -- Could be a tyvar or a tycon @@ -275,10 +275,10 @@ kcClass cls -- Must be a class %* * %************************************************************************ -tcHsSigType and tcHsBoxedSigType +tcHsSigType and tcHsLiftedSigType ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -tcHsSigType and tcHsBoxedSigType are used for type signatures written by the programmer +tcHsSigType and tcHsLiftedSigType are used for type signatures written by the programmer * We hoist any inner for-alls to the top @@ -289,10 +289,10 @@ tcHsSigType and tcHsBoxedSigType are used for type signatures written by the pro so the kind returned is indeed a Kind not a TcKind \begin{code} -tcHsSigType, tcHsBoxedSigType :: RenamedHsType -> TcM Type +tcHsSigType, tcHsLiftedSigType :: RenamedHsType -> TcM Type -- Do kind checking, and hoist for-alls to the top tcHsSigType ty = kcTypeType ty `thenTc_` tcHsType ty -tcHsBoxedSigType ty = kcBoxedType ty `thenTc_` tcHsType ty +tcHsLiftedSigType ty = kcLiftedType ty `thenTc_` tcHsType ty tcHsType :: RenamedHsType -> TcM Type tcHsRecType :: RecFlag -> RenamedHsType -> TcM Type diff --git a/ghc/compiler/typecheck/TcPat.lhs b/ghc/compiler/typecheck/TcPat.lhs index e40c63e..882af01 100644 --- a/ghc/compiler/typecheck/TcPat.lhs +++ b/ghc/compiler/typecheck/TcPat.lhs @@ -28,7 +28,7 @@ import CmdLineOpts ( opt_IrrefutableTuples ) import DataCon ( dataConSig, dataConFieldLabels, dataConSourceArity ) -import Type ( isTauTy, mkTyConApp, mkClassPred, boxedTypeKind ) +import Type ( isTauTy, mkTyConApp, mkClassPred, liftedTypeKind ) import Subst ( substTy, substClasses ) import TysPrim ( charPrimTy, intPrimTy, floatPrimTy, doublePrimTy, addrPrimTy @@ -234,7 +234,7 @@ tcPat tc_bndr pat@(RecPatIn name rpats) pat_ty -- If foo isn't one of R's fields, we don't want to crash when -- typechecking the "a+b". [] -> addErrTc (badFieldCon name field_label) `thenNF_Tc_` - newTyVarTy boxedTypeKind `thenNF_Tc_` + newTyVarTy liftedTypeKind `thenNF_Tc_` returnTc (error "Bogus selector Id", pat_ty) -- The normal case, when the field comes from the right constructor diff --git a/ghc/compiler/typecheck/TcTyClsDecls.lhs b/ghc/compiler/typecheck/TcTyClsDecls.lhs index 1bd7312..dc3e8b0 100644 --- a/ghc/compiler/typecheck/TcTyClsDecls.lhs +++ b/ghc/compiler/typecheck/TcTyClsDecls.lhs @@ -25,7 +25,7 @@ import TcEnv ( TcEnv, RecTcEnv, TcTyThing(..), TyThing(..), TyThingDetails(..), tcExtendKindEnv, tcLookup, tcExtendGlobalEnv, tcExtendGlobalValEnv ) import TcTyDecls ( tcTyDecl1, kcConDetails, mkNewTyConRep ) import TcClassDcl ( tcClassDecl1 ) -import TcMonoType ( kcHsTyVars, kcHsType, kcHsBoxedSigType, kcHsContext, mkTyClTyVars ) +import TcMonoType ( kcHsTyVars, kcHsType, kcHsLiftedSigType, kcHsContext, mkTyClTyVars ) import TcType ( TcKind, newKindVar, zonkKindEnv ) import TcUnify ( unifyKind ) @@ -110,7 +110,7 @@ Step 5: tcTyClDecl1 Step 6: tcTyClDecl1 again For a recursive group only, check all the decls again, just but this time with the wimp flag off. Now we can check things - like whether a function argument is an unboxed tuple, looking + like whether a function argument is an unlifted tuple, looking through type synonyms properly. We can't do that in Step 5. Step 7: Extend environment @@ -252,7 +252,7 @@ kcTyClDecl decl@(ClassDecl {tcdCtxt = context, tcdSigs = class_sigs}) kcHsContext context `thenTc_` mapTc_ kc_sig (filter isClassOpSig class_sigs) where - kc_sig (ClassOpSig _ _ op_ty loc) = kcHsBoxedSigType op_ty + kc_sig (ClassOpSig _ _ op_ty loc) = kcHsLiftedSigType op_ty kcTyClDeclBody :: RenamedTyClDecl -> (Kind -> TcM a) -> TcM a -- Extend the env with bindings for the tyvars, taken from diff --git a/ghc/compiler/typecheck/TcTyDecls.lhs b/ghc/compiler/typecheck/TcTyDecls.lhs index 9eb3fc7..60657db 100644 --- a/ghc/compiler/typecheck/TcTyDecls.lhs +++ b/ghc/compiler/typecheck/TcTyDecls.lhs @@ -17,7 +17,7 @@ import RnHsSyn ( RenamedTyClDecl, RenamedConDecl, RenamedContext ) import BasicTypes ( NewOrData(..), RecFlag, isRec ) import TcMonoType ( tcHsRecType, tcHsTyVars, tcRecClassContext, - kcHsContext, kcHsSigType, kcHsBoxedSigType + kcHsContext, kcHsSigType, kcHsLiftedSigType ) import TcEnv ( tcExtendTyVarEnv, tcLookupTyCon, tcLookupRecId, @@ -122,9 +122,9 @@ kcConDetails new_or_data ex_ctxt details where kc_sig_type = case new_or_data of DataType -> kcHsSigType - NewType -> kcHsBoxedSigType - -- Can't allow an unboxed type here, because we're effectively - -- going to remove the constructor while coercing it to a boxed type. + NewType -> kcHsLiftedSigType + -- Can't allow an unlifted type here, because we're effectively + -- going to remove the constructor while coercing it to a lifted type. tcConDecl :: RecFlag -> NewOrData -> TyCon -> [TyVar] -> ClassContext -> RenamedConDecl -> TcM DataCon diff --git a/ghc/compiler/typecheck/TcType.lhs b/ghc/compiler/typecheck/TcType.lhs index d03f6f5..6e8fc04 100644 --- a/ghc/compiler/typecheck/TcType.lhs +++ b/ghc/compiler/typecheck/TcType.lhs @@ -47,9 +47,9 @@ import Type ( PredType(..), getTyVar, mkAppTy, mkUTy, splitPredTy_maybe, splitForAllTys, isTyVarTy, mkTyVarTy, mkTyVarTys, - openTypeKind, boxedTypeKind, + openTypeKind, liftedTypeKind, superKind, superBoxity, - defaultKind, boxedBoxity + defaultKind, liftedBoxity ) import Subst ( Subst, mkTopTyVarSubst, substTy ) import TyCon ( mkPrimTyCon ) @@ -318,18 +318,18 @@ zonkKindEnv pairs -- When zonking a kind, we want to -- zonk a *kind* variable to (Type *) -- zonk a *boxity* variable to * - zonk_unbound_kind_var kv | tyVarKind kv == superKind = tcPutTyVar kv boxedTypeKind - | tyVarKind kv == superBoxity = tcPutTyVar kv boxedBoxity + zonk_unbound_kind_var kv | tyVarKind kv == superKind = tcPutTyVar kv liftedTypeKind + | tyVarKind kv == superBoxity = tcPutTyVar kv liftedBoxity | otherwise = pprPanic "zonkKindEnv" (ppr kv) zonkTcTypeToType :: TcType -> NF_TcM Type zonkTcTypeToType ty = zonkType zonk_unbound_tyvar ty where -- Zonk a mutable but unbound type variable to - -- Void if it has kind Boxed + -- Void if it has kind Lifted -- :Void otherwise zonk_unbound_tyvar tv - | kind == boxedTypeKind + | kind == liftedTypeKind = tcPutTyVar tv voidTy -- Just to avoid creating a new tycon in -- this vastly common case | otherwise @@ -359,7 +359,7 @@ zonkTcTyVarToTyVar :: TcTyVar -> NF_TcM TyVar zonkTcTyVarToTyVar tv = let -- Make an immutable version, defaulting - -- the kind to boxed if necessary + -- the kind to lifted if necessary immut_tv = mkTyVar (tyVarName tv) (defaultKind (tyVarKind tv)) immut_tv_ty = mkTyVarTy immut_tv diff --git a/ghc/compiler/typecheck/TcUnify.lhs b/ghc/compiler/typecheck/TcUnify.lhs index f9ebae4..b732b0d 100644 --- a/ghc/compiler/typecheck/TcUnify.lhs +++ b/ghc/compiler/typecheck/TcUnify.lhs @@ -17,7 +17,7 @@ module TcUnify ( unifyTauTy, unifyTauTyList, unifyTauTyLists, -- friends: import TcMonad import TypeRep ( Type(..), PredType(..) ) -- friend -import Type ( unboxedTypeKind, boxedTypeKind, openTypeKind, +import Type ( unliftedTypeKind, liftedTypeKind, openTypeKind, typeCon, openKindCon, hasMoreBoxityInfo, tyVarsOfType, typeKind, mkFunTy, splitFunTy_maybe, splitTyConApp_maybe, @@ -371,9 +371,9 @@ uUnboundVar swapped tv1 maybe_ty1 ps_ty2 non_var_ty2 checkKinds swapped tv1 ty2 -- We're about to unify a type variable tv1 with a non-tyvar-type ty2. --- We need to check that we don't unify a boxed type variable with an --- unboxed type: e.g. (id 3#) is illegal - | tk1 == boxedTypeKind && tk2 == unboxedTypeKind +-- We need to check that we don't unify a lifted type variable with an +-- unlifted type: e.g. (id 3#) is illegal + | tk1 == liftedTypeKind && tk2 == unliftedTypeKind = tcAddErrCtxtM (unifyKindCtxt swapped tv1 ty2) $ unifyMisMatch k1 k2 | otherwise @@ -432,7 +432,7 @@ unifyListTy ty other -> unify_list_ty_help ty unify_list_ty_help ty -- Revert to ordinary unification - = newTyVarTy boxedTypeKind `thenNF_Tc` \ elt_ty -> + = newTyVarTy liftedTypeKind `thenNF_Tc` \ elt_ty -> unifyTauTy ty (mkListTy elt_ty) `thenTc_` returnTc elt_ty \end{code} @@ -459,7 +459,7 @@ unify_tuple_ty_help boxity arity ty unifyTauTy ty (mkTupleTy boxity arity arg_tys) `thenTc_` returnTc arg_tys where - kind | isBoxed boxity = boxedTypeKind + kind | isBoxed boxity = liftedTypeKind | otherwise = openTypeKind \end{code} diff --git a/ghc/compiler/types/PprType.lhs b/ghc/compiler/types/PprType.lhs index 87ddcfa..dc4fa40 100644 --- a/ghc/compiler/types/PprType.lhs +++ b/ghc/compiler/types/PprType.lhs @@ -18,7 +18,7 @@ module PprType( -- friends: -- (PprType can see all the representations it's trying to print) -import TypeRep ( Type(..), TyNote(..), Kind, boxedTypeKind ) -- friend +import TypeRep ( Type(..), TyNote(..), Kind, liftedTypeKind ) -- friend import Type ( PredType(..), ThetaType, splitPredTy_maybe, splitForAllTys, splitSigmaTy, splitRhoTy, @@ -237,7 +237,7 @@ and when in debug mode. \begin{code} pprTyVarBndr tyvar = getPprStyle $ \ sty -> - if (ifaceStyle sty && kind /= boxedTypeKind) || debugStyle sty then + if (ifaceStyle sty && kind /= liftedTypeKind) || debugStyle sty then hsep [ppr tyvar, dcolon, pprParendKind kind] -- See comments with ppDcolon in PprCore.lhs else diff --git a/ghc/compiler/types/Type.lhs b/ghc/compiler/types/Type.lhs index 7ef2765..0d88be1 100644 --- a/ghc/compiler/types/Type.lhs +++ b/ghc/compiler/types/Type.lhs @@ -10,10 +10,10 @@ module Type ( Kind, TyVarSubst, superKind, superBoxity, -- KX and BX respectively - boxedBoxity, unboxedBoxity, -- :: BX + liftedBoxity, unliftedBoxity, -- :: BX openKindCon, -- :: KX typeCon, -- :: BX -> KX - boxedTypeKind, unboxedTypeKind, openTypeKind, -- :: KX + liftedTypeKind, unliftedTypeKind, openTypeKind, -- :: KX mkArrowKind, mkArrowKinds, -- :: KX -> KX -> KX funTyCon, @@ -61,7 +61,7 @@ module Type ( getDFunTyKey, -- Lifting and boxity - isUnLiftedType, isUnboxedType, isUnboxedTupleType, isAlgType, isDataType, isNewType, + isUnLiftedType, isUnboxedTupleType, isAlgType, isDataType, isNewType, -- Free variables tyVarsOfType, tyVarsOfTypes, tyVarsOfPred, tyVarsOfTheta, @@ -110,7 +110,7 @@ import TyCon ( TyCon, -- others import Maybes ( maybeToBool ) import SrcLoc ( noSrcLoc ) -import PrimRep ( PrimRep(..), isFollowableRep ) +import PrimRep ( PrimRep(..) ) import Unique ( Uniquable(..) ) import Util ( mapAccumL, seqList, thenCmp ) import Outputable @@ -132,7 +132,7 @@ hasMoreBoxityInfo k1 k2 defaultKind :: Kind -> Kind -- Used when generalising: default kind '?' to '*' -defaultKind kind | kind == openTypeKind = boxedTypeKind +defaultKind kind | kind == openTypeKind = liftedTypeKind | otherwise = kind \end{code} @@ -845,19 +845,19 @@ typeKind :: Type -> Kind typeKind (TyVarTy tyvar) = tyVarKind tyvar typeKind (TyConApp tycon tys) = foldr (\_ k -> funResultTy k) (tyConKind tycon) tys typeKind (NoteTy _ ty) = typeKind ty -typeKind (PredTy _) = boxedTypeKind -- Predicates are always - -- represented by boxed types +typeKind (PredTy _) = liftedTypeKind -- Predicates are always + -- represented by lifted types typeKind (AppTy fun arg) = funResultTy (typeKind fun) typeKind (FunTy arg res) = fix_up (typeKind res) where fix_up (TyConApp tycon _) | tycon == typeCon - || tycon == openKindCon = boxedTypeKind + || tycon == openKindCon = liftedTypeKind fix_up (NoteTy _ kind) = fix_up kind fix_up kind = kind -- The basic story is -- typeKind (FunTy arg res) = typeKind res - -- But a function is boxed regardless of its result type + -- But a function is lifted regardless of its result type -- Hence the strange fix-up. -- Note that 'res', being the result of a FunTy, can't have -- a strange kind like (*->*). @@ -1023,14 +1023,11 @@ tidyTopType ty = tidyType emptyTidyEnv ty %************************************************************************ %* * -\subsection{Boxedness and liftedness} +\subsection{Liftedness} %* * %************************************************************************ \begin{code} -isUnboxedType :: Type -> Bool -isUnboxedType ty = not (isFollowableRep (typePrimRep ty)) - isUnLiftedType :: Type -> Bool -- isUnLiftedType returns True for forall'd unlifted types: -- x :: forall a. Int# diff --git a/ghc/compiler/types/TypeRep.lhs b/ghc/compiler/types/TypeRep.lhs index 2a9acad..1770772 100644 --- a/ghc/compiler/types/TypeRep.lhs +++ b/ghc/compiler/types/TypeRep.lhs @@ -11,10 +11,10 @@ module TypeRep ( TyVarSubst, superKind, superBoxity, -- KX and BX respectively - boxedBoxity, unboxedBoxity, -- :: BX + liftedBoxity, unliftedBoxity, -- :: BX openKindCon, -- :: KX typeCon, -- :: BX -> KX - boxedTypeKind, unboxedTypeKind, openTypeKind, -- :: KX + liftedTypeKind, unliftedTypeKind, openTypeKind, -- :: KX mkArrowKind, mkArrowKinds, -- :: KX -> KX -> KX usageKindCon, -- :: KX @@ -37,9 +37,10 @@ import TyCon ( TyCon, KindCon, mkFunTyCon, mkKindCon, mkSuperKindCon ) import Class ( Class ) -- others -import PrelNames ( superKindName, superBoxityName, boxedConName, - unboxedConName, typeConName, openKindConName, funTyConName, - usageKindConName, usOnceTyConName, usManyTyConName +import PrelNames ( superKindName, superBoxityName, liftedConName, + unliftedConName, typeConName, openKindConName, + usageKindConName, usOnceTyConName, usManyTyConName, + funTyConName ) \end{code} @@ -52,15 +53,15 @@ import PrelNames ( superKindName, superBoxityName, boxedConName, A type is *unboxed* iff its representation is other than a pointer - Unboxed types cannot instantiate a type variable. - Unboxed types are always unlifted. + Unboxed types are also unlifted. *lifted* A type is lifted iff it has bottom as an element. Closures always have lifted types: i.e. any let-bound identifier in Core must have a lifted type. Operationally, a lifted object is one that can be entered. - (NOTE: previously "pointed"). + + Only lifted types may be unified with a type variable. *algebraic* A type with one or more constructors, whether declared with "data" or "newtype". @@ -189,18 +190,18 @@ Kinds ~~~~~ kind :: KX = kind -> kind - | Type boxity -- (Type *) is printed as just * + | Type liftedness -- (Type *) is printed as just * -- (Type #) is printed as just # | UsageKind -- Printed '$'; used for usage annotations - | OpenKind -- Can be boxed or unboxed + | OpenKind -- Can be lifted or unlifted -- Printed '?' | kv -- A kind variable; *only* happens during kind checking -boxity :: BX = * -- Boxed - | # -- Unboxed +boxity :: BX = * -- Lifted + | # -- Unlifted | bv -- A boxity variable; *only* happens during kind checking There's a little subtyping at the kind level: @@ -213,13 +214,14 @@ in two situations: 1. The universally quantified type variable(s) for special built-in things like error :: forall (a::?). String -> a. - Here, the 'a' can be instantiated to a boxed or unboxed type. + Here, the 'a' can be instantiated to a lifted or unlifted type. 2. Kind '?' is also used when the typechecker needs to create a fresh type variable, one that may very well later be unified with a type. For example, suppose f::a, and we see an application (f x). Then a must be a function type, so we unify a with (b->c). But what kind - are b and c? They can be boxed or unboxed types, so we give them kind '?'. + are b and c? They can be lifted or unlifted types, so we give them + kind '?'. When the type checker generalises over a bunch of type variables, it makes any that still have kind '?' into kind '*'. So kind '?' is never @@ -242,10 +244,10 @@ superBoxity = TyConApp (mkSuperKindCon superBoxityName) [] Define boxities: @*@ and @#@ \begin{code} -boxedBoxity, unboxedBoxity :: Kind -- :: BX -boxedBoxity = TyConApp (mkKindCon boxedConName superBoxity) [] +liftedBoxity, unliftedBoxity :: Kind -- :: BX +liftedBoxity = TyConApp (mkKindCon liftedConName superBoxity) [] -unboxedBoxity = TyConApp (mkKindCon unboxedConName superBoxity) [] +unliftedBoxity = TyConApp (mkKindCon unliftedConName superBoxity) [] \end{code} ------------------------------------------ @@ -255,10 +257,10 @@ Define kinds: Type, Type *, Type #, OpenKind, and UsageKind typeCon :: KindCon -- :: BX -> KX typeCon = mkKindCon typeConName (superBoxity `FunTy` superKind) -boxedTypeKind, unboxedTypeKind, openTypeKind :: Kind -- Of superkind superKind +liftedTypeKind, unliftedTypeKind, openTypeKind :: Kind -- Of superkind superKind -boxedTypeKind = TyConApp typeCon [boxedBoxity] -unboxedTypeKind = TyConApp typeCon [unboxedBoxity] +liftedTypeKind = TyConApp typeCon [liftedBoxity] +unliftedTypeKind = TyConApp typeCon [unliftedBoxity] openKindCon = mkKindCon openKindConName superKind openTypeKind = TyConApp openKindCon [] @@ -288,7 +290,7 @@ mkArrowKinds arg_kinds result_kind = foldr mkArrowKind result_kind arg_kinds We define a few wired-in type constructors here to avoid module knots \begin{code} -funTyCon = mkFunTyCon funTyConName (mkArrowKinds [boxedTypeKind, boxedTypeKind] boxedTypeKind) +funTyCon = mkFunTyCon funTyConName (mkArrowKinds [liftedTypeKind, liftedTypeKind] liftedTypeKind) \end{code} ------------------------------------------