Extended TyCon and friends to represent family declarations
[ghc-hetmet.git] / compiler / iface / MkIface.lhs
index 656ba36..7901f7c 100644 (file)
@@ -11,8 +11,10 @@ module MkIface (
 
        writeIfaceFile, -- Write the interface file
 
-       checkOldIface   -- See if recompilation is required, by
+       checkOldIface,  -- See if recompilation is required, by
                        -- comparing version information
+
+        tyThingToIfaceDecl -- Converting things to their Iface equivalents
  ) where
 \end{code}
 
@@ -183,10 +185,11 @@ import IdInfo             ( IdInfo, CafInfo(..), WorkerInfo(..),
 import NewDemand       ( isTopSig )
 import CoreSyn
 import Class           ( classExtraBigSig, classTyCon )
-import TyCon           ( TyCon, AlgTyConRhs(..), isRecursiveTyCon, isForeignTyCon,
+import TyCon           ( TyCon, AlgTyConRhs(..), SynTyConRhs(..),
+                         isRecursiveTyCon, isForeignTyCon, 
                          isSynTyCon, isAlgTyCon, isPrimTyCon, isFunTyCon,
                          isTupleTyCon, tupleTyConBoxity, tyConStupidTheta,
-                         tyConHasGenerics, tyConArgVrcs, synTyConRhs, isGadtSyntaxTyCon,
+                         tyConHasGenerics, synTyConRhs, isGadtSyntaxTyCon,
                          tyConArity, tyConTyVars, algTyConRhs, tyConExtName  )
 import DataCon         ( dataConName, dataConFieldLabels, dataConStrictMarks,
                          dataConTyCon, dataConIsInfix, dataConUnivTyVars, dataConExTyVars, dataConEqSpec,
@@ -995,8 +998,7 @@ tyThingToIfaceDecl ext (AClass clas)
                 ifTyVars = toIfaceTvBndrs clas_tyvars,
                 ifFDs    = map toIfaceFD clas_fds,
                 ifSigs   = map toIfaceClassOp op_stuff,
-                ifRec    = boolToRecFlag (isRecursiveTyCon tycon),
-                ifVrcs   = tyConArgVrcs tycon }
+                ifRec    = boolToRecFlag (isRecursiveTyCon tycon) }
   where
     (clas_tyvars, clas_fds, sc_theta, _, op_stuff) = classExtraBigSig clas
     tycon = classTyCon clas
@@ -1017,10 +1019,10 @@ tyThingToIfaceDecl ext (AClass clas)
 
 tyThingToIfaceDecl ext (ATyCon tycon)
   | isSynTyCon tycon
-  = IfaceSyn { ifName   = getOccName tycon,
-               ifTyVars = toIfaceTvBndrs tyvars,
-               ifVrcs    = tyConArgVrcs tycon,
-               ifSynRhs = toIfaceType ext syn_ty }
+  = IfaceSyn { ifName    = getOccName tycon,
+               ifTyVars  = toIfaceTvBndrs tyvars,
+               ifOpenSyn = syn_isOpen,
+               ifSynRhs  = toIfaceType ext syn_tyki }
 
   | isAlgTyCon tycon
   = IfaceData {        ifName    = getOccName tycon,
@@ -1029,7 +1031,6 @@ tyThingToIfaceDecl ext (ATyCon tycon)
                ifCons    = ifaceConDecls (algTyConRhs tycon),
                ifRec     = boolToRecFlag (isRecursiveTyCon tycon),
                ifGadtSyntax = isGadtSyntaxTyCon tycon,
-               ifVrcs    = tyConArgVrcs tycon,
                ifGeneric = tyConHasGenerics tycon }
 
   | isForeignTyCon tycon
@@ -1044,16 +1045,21 @@ tyThingToIfaceDecl ext (ATyCon tycon)
                ifCons    = IfAbstractTyCon,
                ifGadtSyntax = False,
                ifGeneric = False,
-               ifRec     = NonRecursive,
-               ifVrcs    = tyConArgVrcs tycon }
+               ifRec     = NonRecursive}
 
   | otherwise = pprPanic "toIfaceDecl" (ppr tycon)
   where
     tyvars = tyConTyVars tycon
-    syn_ty = synTyConRhs tycon
-
-    ifaceConDecls (NewTyCon { data_con = con })    = IfNewTyCon  (ifaceConDecl con)
-    ifaceConDecls (DataTyCon { data_cons = cons }) = IfDataTyCon (map ifaceConDecl cons)
+    (syn_isOpen, syn_tyki) = case synTyConRhs tycon of
+                              OpenSynTyCon ki -> (True , ki)
+                              SynonymTyCon ty -> (False, ty)
+
+    ifaceConDecls (NewTyCon { data_con = con })    = 
+      IfNewTyCon  (ifaceConDecl con)
+    ifaceConDecls (DataTyCon { data_cons = cons }) = 
+      IfDataTyCon (map ifaceConDecl cons)
+    ifaceConDecls OpenDataTyCon                    = IfOpenDataTyCon
+    ifaceConDecls OpenNewTyCon                     = IfOpenNewTyCon
     ifaceConDecls AbstractTyCon                           = IfAbstractTyCon
        -- The last case happens when a TyCon has been trimmed during tidying
        -- Furthermore, tyThingToIfaceDecl is also used