X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Fprelude%2FTysPrim.lhs;h=efeced286c5ec26a5baa4c18ef7f54f92331d1e8;hb=5e3c9a59c4827b1fbde59461076b4839d57efd7c;hp=4e1576f9f0f2d2cbbbdf2e6476f99a68d3560bcc;hpb=388e3356f71daffa62f1d4157e1e07e4c68f218a;p=ghc-hetmet.git diff --git a/compiler/prelude/TysPrim.lhs b/compiler/prelude/TysPrim.lhs index 4e1576f..efeced2 100644 --- a/compiler/prelude/TysPrim.lhs +++ b/compiler/prelude/TysPrim.lhs @@ -12,6 +12,7 @@ module TysPrim( alphaTyVars, betaTyVars, alphaTyVar, betaTyVar, gammaTyVar, deltaTyVar, alphaTy, betaTy, gammaTy, deltaTy, openAlphaTy, openBetaTy, openAlphaTyVar, openBetaTyVar, openAlphaTyVars, + argAlphaTy, argAlphaTyVar, primTyCons, @@ -46,7 +47,7 @@ module TysPrim( word64PrimTyCon, word64PrimTy, -- * Any - anyTyCon, anyType, anyTyConOfKind, anyTypeOfKind + anyTyCon, anyTyConOfKind, anyTypeOfKind ) where #include "HsVersions.h" @@ -57,6 +58,7 @@ import OccName ( mkTcOcc ) import OccName ( mkTyVarOccFS, mkTcOccFS ) import TyCon ( TyCon, mkPrimTyCon, mkLiftedPrimTyCon, mkAnyTyCon ) import Type +import Coercion import SrcLoc import Unique ( mkAlphaTyVarUnique ) import PrelNames @@ -179,7 +181,12 @@ openAlphaTyVars@(openAlphaTyVar:openBetaTyVar:_) = tyVarList openTypeKind openAlphaTy, openBetaTy :: Type openAlphaTy = mkTyVarTy openAlphaTyVar -openBetaTy = mkTyVarTy openBetaTyVar +openBetaTy = mkTyVarTy openBetaTyVar + +argAlphaTyVar :: TyVar +(argAlphaTyVar : _) = tyVarList argTypeKind +argAlphaTy :: Type +argAlphaTy = mkTyVarTy argAlphaTyVar \end{code} @@ -232,8 +239,13 @@ Note [Uniques of Any] Although Any(*->*), say, doesn't have a binding site, it still needs to have a Unique. Unlike tuples (which are also an infinite family) there is no convenient way to index them, so we use the Unique from -their OccName instead. That should be unique! (But in principle we -must take care: it does not include the module/package.) +their OccName instead. That should be unique, + - both wrt each other, because their strings differ + + - and wrt any other Name, because Names get uniques with + various 'char' tags, but the OccName of Any will + get a Unique built with mkTcOccUnique, which has a particular 'char' + tag; see Unique.mkTcOccUnique! Note [Strangely-kinded void TyCons] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -262,22 +274,14 @@ anyTyConName = mkPrimTc (fsLit "Any") anyTyConKey anyTyCon anyTyCon :: TyCon anyTyCon = mkLiftedPrimTyCon anyTyConName liftedTypeKind 0 PtrRep -anyType :: Type -anyType = mkTyConApp anyTyCon [] - anyTypeOfKind :: Kind -> Type -anyTypeOfKind kind - | isLiftedTypeKind kind = anyType - | otherwise = mkTyConApp (mk_any_tycon kind) [] +anyTypeOfKind kind = mkTyConApp (anyTyConOfKind kind) [] anyTyConOfKind :: Kind -> TyCon +-- Map all superkinds of liftedTypeKind to liftedTypeKind anyTyConOfKind kind - | isLiftedTypeKind kind = anyTyCon - | otherwise = mk_any_tycon kind - -mk_any_tycon :: Kind -> TyCon -mk_any_tycon kind -- Kind other than * - = tycon + | liftedTypeKind `isSubKind` kind = anyTyCon + | otherwise = tycon where -- Derive the name from the kind, thus: -- Any(*->*), Any(*->*->*)