Improve External Core syntax for newtypes
[ghc-hetmet.git] / utils / ext-core / Core.hs
index 5f8ed82..0fb48b8 100644 (file)
@@ -9,14 +9,15 @@ data Module
 
 data Tdef 
   = Data (Qual Tcon) [Tbind] [Cdef]
-  | Newtype (Qual Tcon) [Tbind] Axiom (Maybe Ty)
+    -- type constructor; coercion name; type arguments; type rep
+    -- If we have: (Newtype tc co tbs (Just t))
+    -- there is an implicit axiom:
+    --  co tbs :: tc tbs :=: t
+  | Newtype (Qual Tcon) (Qual Tcon) [Tbind] (Maybe Ty)
 
 data Cdef 
   = Constr (Qual Dcon) [Tbind] [Ty]
 
--- Newtype coercion
-type Axiom = (Qual Tcon, [Tbind], (Ty,Ty))
-
 data Vdefg 
   = Rec [Vdef]
   | Nonrec Vdef
@@ -60,6 +61,7 @@ data Ty
   | TransCoercion Ty Ty
   | SymCoercion Ty
   | UnsafeCoercion Ty Ty
+  | InstCoercion Ty Ty
   | LeftCoercion Ty
   | RightCoercion Ty
 
@@ -132,9 +134,9 @@ eqKind Kunlifted Kunlifted = True
 eqKind Kopen Kopen = True
 eqKind (Karrow k1 k2) (Karrow l1 l2) = k1 `eqKind` l1
                                    &&  k2 `eqKind` l2
-eqKind _ _ = False -- no Keq kind is ever equal to any other...
-                   -- maybe ok for now?
-
+eqKind (Keq t1 t2) (Keq u1 u2) = t1 == u1
+                              && t2 == u2
+eqKind _ _ = False
 
 splitTyConApp_maybe :: Ty -> Maybe (Qual Tcon,[Ty])
 splitTyConApp_maybe (Tvar _) = Nothing