Commit 6d0b77ef authored by simonpj@microsoft.com's avatar simonpj@microsoft.com
Browse files

Tidy up AnyTyCon stuff

If we find ourselves making up an AnyTyCon of kind '??', say, 
then default it to liftedTypeKind.  And similarly for any sub-kind
of LiftedTypeKind.

This is just a tidy-up.
parent 06f69692
...@@ -46,7 +46,7 @@ module TysPrim( ...@@ -46,7 +46,7 @@ module TysPrim(
word64PrimTyCon, word64PrimTy, word64PrimTyCon, word64PrimTy,
-- * Any -- * Any
anyTyCon, anyType, anyTyConOfKind, anyTypeOfKind anyTyCon, anyTyConOfKind, anyTypeOfKind
) where ) where
#include "HsVersions.h" #include "HsVersions.h"
...@@ -234,7 +234,6 @@ Although Any(*->*), say, doesn't have a binding site, it still needs ...@@ -234,7 +234,6 @@ Although Any(*->*), say, doesn't have a binding site, it still needs
to have a Unique. Unlike tuples (which are also an infinite family) 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 there is no convenient way to index them, so we use the Unique from
their OccName instead. That should be unique, their OccName instead. That should be unique,
- both wrt each other, because their strings differ - both wrt each other, because their strings differ
- and wrt any other Name, because Names get uniques with - and wrt any other Name, because Names get uniques with
...@@ -269,22 +268,14 @@ anyTyConName = mkPrimTc (fsLit "Any") anyTyConKey anyTyCon ...@@ -269,22 +268,14 @@ anyTyConName = mkPrimTc (fsLit "Any") anyTyConKey anyTyCon
anyTyCon :: TyCon anyTyCon :: TyCon
anyTyCon = mkLiftedPrimTyCon anyTyConName liftedTypeKind 0 PtrRep anyTyCon = mkLiftedPrimTyCon anyTyConName liftedTypeKind 0 PtrRep
anyType :: Type
anyType = mkTyConApp anyTyCon []
anyTypeOfKind :: Kind -> Type anyTypeOfKind :: Kind -> Type
anyTypeOfKind kind anyTypeOfKind kind = mkTyConApp (anyTyConOfKind kind) []
| isLiftedTypeKind kind = anyType
| otherwise = mkTyConApp (mk_any_tycon kind) []
anyTyConOfKind :: Kind -> TyCon anyTyConOfKind :: Kind -> TyCon
-- Map all superkinds of liftedTypeKind to liftedTypeKind
anyTyConOfKind kind anyTyConOfKind kind
| isLiftedTypeKind kind = anyTyCon | liftedTypeKind `isSubKind` kind = anyTyCon
| otherwise = mk_any_tycon kind | otherwise = tycon
mk_any_tycon :: Kind -> TyCon
mk_any_tycon kind -- Kind other than *
= tycon
where where
-- Derive the name from the kind, thus: -- Derive the name from the kind, thus:
-- Any(*->*), Any(*->*->*) -- Any(*->*), Any(*->*->*)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment