summaryrefslogtreecommitdiff
path: root/compiler/prelude
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2011-05-26 17:19:18 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2011-05-26 17:19:18 +0100
commit3afdf90d0f9fb18f13a6b76fe41e5fc60bbdaac3 (patch)
tree70e7ece16dfdfdf62b4e84a170d357a39370c93d /compiler/prelude
parent80f5e7009434750cee746bd89f7eea5f7c7fa3fd (diff)
downloadhaskell-3afdf90d0f9fb18f13a6b76fe41e5fc60bbdaac3.tar.gz
Treat the (~) type constructor a bit specially
when kind-checking in Core Lint. It's unusual becuase it is poly-kinded; for example (~) Int a and (~) Maybe b are both ok. We don't want the full generality of kind polymorphism (yet anyway) so these changes in effect give (~) its own private kinding rule. It won't work right if (~) appears un-saturated, and Lint now checks for that too.
Diffstat (limited to 'compiler/prelude')
-rw-r--r--compiler/prelude/TysPrim.lhs20
1 files changed, 18 insertions, 2 deletions
diff --git a/compiler/prelude/TysPrim.lhs b/compiler/prelude/TysPrim.lhs
index 4b3492b2c0..d0495d7b29 100644
--- a/compiler/prelude/TysPrim.lhs
+++ b/compiler/prelude/TysPrim.lhs
@@ -379,6 +379,22 @@ doublePrimTyCon = pcPrimTyCon0 doublePrimTyConName DoubleRep
%* *
%************************************************************************
+Note [The (~) TyCon)
+~~~~~~~~~~~~~~~~~~~~
+There is a perfectly ordinary type constructor (~) that represents the type
+of coercions (which, remember, are values). For example
+ Refl Int :: Int ~ Int
+
+Atcually it is not quite "perfectly ordinary" because it is kind-polymorphic:
+ Refl Maybe :: Maybe ~ Maybe
+
+So the true kind of (~) :: forall k. k -> k -> #. But we don't have
+polymorphic kinds (yet). However, (~) really only appears saturated in
+which case there is no problem in finding the kind of (ty1 ~ ty2). So
+we check that in CoreLint (and, in an assertion, in Kind.typeKind).
+
+Note [The State# TyCon]
+~~~~~~~~~~~~~~~~~~~~~~~
State# is the primitive, unlifted type of states. It has one type parameter,
thus
State# RealWorld
@@ -392,10 +408,11 @@ keep different state threads separate. It is represented by nothing at all.
mkStatePrimTy :: Type -> Type
mkStatePrimTy ty = mkTyConApp statePrimTyCon [ty]
-statePrimTyCon :: TyCon
+statePrimTyCon :: TyCon -- See Note [The State# TyCon]
statePrimTyCon = pcPrimTyCon statePrimTyConName 1 VoidRep
eqPredPrimTyCon :: TyCon -- The representation type for equality predicates
+ -- See Note [The (~) TyCon]
eqPredPrimTyCon = pcPrimTyCon eqPredPrimTyConName 2 VoidRep
\end{code}
@@ -415,7 +432,6 @@ realWorldStatePrimTy = mkStatePrimTy realWorldTy -- State# RealWorld
Note: the ``state-pairing'' types are not truly primitive, so they are
defined in \tr{TysWiredIn.lhs}, not here.
-
%************************************************************************
%* *
\subsection[TysPrim-arrays]{The primitive array types}