liftedTypeKind, unliftedTypeKind, openTypeKind, -- :: KX
mkArrowKind, mkArrowKinds, -- :: KX -> KX -> KX
- usageKindCon, -- :: KX
- usageTypeKind, -- :: KX
- usOnceTyCon, usManyTyCon, -- :: $
- usOnce, usMany, -- :: $
-
funTyCon
) where
-- others
import PrelNames ( superKindName, superBoxityName, liftedConName,
unliftedConName, typeConName, openKindConName,
- usageKindConName, usOnceTyConName, usManyTyConName,
funTyConName
)
\end{code}
| Type liftedness -- (Type *) is printed as just *
-- (Type #) is printed as just #
- | UsageKind -- Printed '$'; used for usage annotations
-
| OpenKind -- Can be lifted or unlifted
-- Printed '?'
\end{code}
------------------------------------------
-Define kinds: Type, Type *, Type #, OpenKind, and UsageKind
+Define kinds: Type, Type *, Type #, OpenKind
\begin{code}
typeCon :: KindCon -- :: BX -> KX
openKindCon = mkKindCon openKindConName superKind
openTypeKind = TyConApp openKindCon []
-
-usageKindCon = mkKindCon usageKindConName superKind
-usageTypeKind = TyConApp usageKindCon []
\end{code}
------------------------------------------
instance Binary Kind where
put_ bh k@(TyConApp tc [])
| tc == openKindCon = putByte bh 0
- | tc == usageKindCon = putByte bh 1
put_ bh k@(TyConApp tc [TyConApp bc _])
| tc == typeCon && bc == liftedBoxityCon = putByte bh 2
| tc == typeCon && bc == unliftedBoxityCon = putByte bh 3
b <- getByte bh
case b of
0 -> return openTypeKind
- 1 -> return usageTypeKind
2 -> return liftedTypeKind
3 -> return unliftedTypeKind
_ -> do f <- get bh; a <- get bh; return (FunTy f a)
\begin{code}
funTyCon = mkFunTyCon funTyConName (mkArrowKinds [liftedTypeKind, liftedTypeKind] liftedTypeKind)
+ -- You might think that (->) should have type (? -> ? -> *), and you'd be right
+ -- But if we do that we get kind errors when saying
+ -- instance Control.Arrow (->)
+ -- becuase the expected kind is (*->*->*). The trouble is that the
+ -- expected/actual stuff in the unifier does not go contra-variant, whereas
+ -- the kind sub-typing does. Sigh. It really only matters if you use (->) in
+ -- a prefix way, thus: (->) Int# Int#. And this is unusual.
\end{code}
-------------------------------------------
-Usage tycons @.@ and @!@
-
-The usage tycons are of kind usageTypeKind (`$'). The types contain
-no values, and are used purely for usage annotation.
-
-\begin{code}
-usOnceTyCon = mkKindCon usOnceTyConName usageTypeKind
-usOnce = TyConApp usOnceTyCon []
-
-usManyTyCon = mkKindCon usManyTyConName usageTypeKind
-usMany = TyConApp usManyTyCon []
-\end{code}