\section[Kind]{The @Kind@ datatype}
\begin{code}
+#include "HsVersions.h"
+
module Kind (
Kind(..), -- Only visible to friends: TcKind
mkUnboxedTypeKind,
mkBoxedTypeKind,
- isSubKindOf,
- resultKind, argKind
+ hasMoreBoxityInfo,
+ resultKind, argKind,
+
+ isUnboxedKind, isTypeKind,
+ notArrowKind
) where
-import Ubiq{-uitous-}
+IMP_Ubiq(){-uitous-}
-import Util ( panic )
-import Outputable ( Outputable(..) )
+import Util ( panic, assertPanic )
+--import Outputable ( Outputable(..) )
import Pretty
\end{code}
mkUnboxedTypeKind = UnboxedTypeKind
mkBoxedTypeKind = BoxedTypeKind
-isSubKindOf :: Kind -> Kind -> Bool
+isTypeKind :: Kind -> Bool
+isTypeKind TypeKind = True
+isTypeKind other = False
+
+isUnboxedKind :: Kind -> Bool
+isUnboxedKind UnboxedTypeKind = True
+isUnboxedKind other = False
+
+hasMoreBoxityInfo :: Kind -> Kind -> Bool
+
+BoxedTypeKind `hasMoreBoxityInfo` TypeKind = True
+BoxedTypeKind `hasMoreBoxityInfo` BoxedTypeKind = True
+
+UnboxedTypeKind `hasMoreBoxityInfo` TypeKind = True
+UnboxedTypeKind `hasMoreBoxityInfo` UnboxedTypeKind = True
+
+TypeKind `hasMoreBoxityInfo` TypeKind = True
+
+kind1@(ArrowKind _ _) `hasMoreBoxityInfo` kind2@(ArrowKind _ _) = ASSERT( kind1 == kind2 )
+ True
+ -- The two kinds can be arrow kinds; for example when unifying
+ -- (m1 Int) and (m2 Int) we end up unifying m1 and m2, which should
+ -- have the same kind.
+
+kind1 `hasMoreBoxityInfo` kind2 = False
-BoxedTypeKind `isSubKindOf` TypeKind = True
-UnboxedTypeKind `isSubKindOf` TypeKind = True
-kind1 `isSubKindOf` kind2 = kind1 == kind2
+notArrowKind (ArrowKind _ _) = False
+notArrowKind other_kind = True
resultKind :: Kind -> Kind -- Get result from arrow kind
resultKind (ArrowKind _ res_kind) = res_kind