Rough matches for family instances
[ghc-hetmet.git] / compiler / iface / BinIface.hs
index 13be049..3e9895a 100644 (file)
@@ -18,11 +18,6 @@ import InstEnv               ( OverlapFlag(..) )
 import Class           ( DefMeth(..) )
 import CostCentre
 import StaticFlags     ( opt_HiVersion, v_Build_tag )
-import Type            ( Kind,
-                          isLiftedTypeKind, isUnliftedTypeKind, isOpenTypeKind,
-                         isArgTypeKind, isUbxTupleKind, liftedTypeKind,
-                         unliftedTypeKind, openTypeKind, argTypeKind,  
-                         ubxTupleKind, mkArrowKind, splitFunTy_maybe )
 import Panic
 import Binary
 import Util
@@ -109,6 +104,7 @@ instance Binary ModIface where
                 mi_deprecs   = deprecs,
                 mi_decls     = decls,
                 mi_insts     = insts,
+                mi_fam_insts = fam_insts,
                 mi_rules     = rules,
                 mi_rule_vers = rule_vers }) = do
        put_ bh (show opt_HiVersion)
@@ -126,6 +122,7 @@ instance Binary ModIface where
        lazyPut bh deprecs
         put_ bh decls
        put_ bh insts
+       put_ bh fam_insts
        lazyPut bh rules
        put_ bh rule_vers
 
@@ -161,6 +158,7 @@ instance Binary ModIface where
        deprecs   <- {-# SCC "bin_deprecs" #-} lazyGet bh
         decls    <- {-# SCC "bin_tycldecls" #-} get bh
        insts     <- {-# SCC "bin_insts" #-} get bh
+       fam_insts <- {-# SCC "bin_fam_insts" #-} get bh
        rules     <- {-# SCC "bin_rules" #-} lazyGet bh
        rule_vers <- get bh
        return (ModIface {
@@ -177,12 +175,13 @@ instance Binary ModIface where
                 mi_decls     = decls,
                 mi_globals   = Nothing,
                 mi_insts     = insts,
+                mi_fam_insts = fam_insts,
                 mi_rules     = rules,
                 mi_rule_vers = rule_vers,
                        -- And build the cached values
-                mi_dep_fn = mkIfaceDepCache deprecs,
-                mi_fix_fn = mkIfaceFixCache fixities,
-                mi_ver_fn = mkIfaceVerCache decls })
+                mi_dep_fn    = mkIfaceDepCache deprecs,
+                mi_fix_fn    = mkIfaceFixCache fixities,
+                mi_ver_fn    = mkIfaceVerCache decls })
 
 GLOBAL_VAR(v_IgnoreHiWay, False, Bool)
 
@@ -365,19 +364,9 @@ instance Binary Fixity where
          return (Fixity aa ab)
 
 instance (Binary name) => Binary (IPName name) where
-    put_ bh (Dupable aa) = do
-           putByte bh 0
-           put_ bh aa
-    put_ bh (Linear ab) = do
-           putByte bh 1
-           put_ bh ab
-    get bh = do
-           h <- getByte bh
-           case h of
-             0 -> do aa <- get bh
-                     return (Dupable aa)
-             _ -> do ab <- get bh
-                     return (Linear ab)
+    put_ bh (IPName aa) = put_ bh aa
+    get bh = do aa <- get bh
+               return (IPName aa)
 
 -------------------------------------------------------------------------
 --             Types from: Demand
@@ -903,7 +892,7 @@ instance Binary IfaceDecl where
            put_ bh idinfo
     put_ bh (IfaceForeign ae af) = 
        error "Binary.put_(IfaceDecl): IfaceForeign"
-    put_ bh (IfaceData a1 a2 a3 a4 a5 a6 a7) = do
+    put_ bh (IfaceData a1 a2 a3 a4 a5 a6 a7 a8) = do
            putByte bh 2
            put_ bh a1
            put_ bh a2
@@ -912,13 +901,14 @@ instance Binary IfaceDecl where
            put_ bh a5
            put_ bh a6
            put_ bh a7
-
-    put_ bh (IfaceSyn aq ar as) = do
+           put_ bh a8
+    put_ bh (IfaceSyn aq ar as at) = do
            putByte bh 3
            put_ bh aq
            put_ bh ar
            put_ bh as
-    put_ bh (IfaceClass a1 a2 a3 a4 a5 a6) = do
+           put_ bh at
+    put_ bh (IfaceClass a1 a2 a3 a4 a5 a6 a7) = do
            putByte bh 4
            put_ bh a1
            put_ bh a2
@@ -926,6 +916,7 @@ instance Binary IfaceDecl where
            put_ bh a4
            put_ bh a5
            put_ bh a6
+           put_ bh a7
     get bh = do
            h <- getByte bh
            case h of
@@ -942,12 +933,14 @@ instance Binary IfaceDecl where
                    a5 <- get bh
                    a6 <- get bh
                    a7 <- get bh
-                   return (IfaceData a1 a2 a3 a4 a5 a6 a7)
+                   a8 <- get bh
+                   return (IfaceData a1 a2 a3 a4 a5 a6 a7 a8)
              3 -> do
                    aq <- get bh
                    ar <- get bh
                    as <- get bh
-                   return (IfaceSyn aq ar as)
+                   at <- get bh
+                   return (IfaceSyn aq ar as at)
              _ -> do
                    a1 <- get bh
                    a2 <- get bh
@@ -955,7 +948,8 @@ instance Binary IfaceDecl where
                    a4 <- get bh
                    a5 <- get bh
                    a6 <- get bh
-                   return (IfaceClass a1 a2 a3 a4 a5 a6)
+                   a7 <- get bh
+                   return (IfaceClass a1 a2 a3 a4 a5 a6 a7)
 
 instance Binary IfaceInst where
     put_ bh (IfaceInst cls tys dfun flag orph) = do
@@ -971,6 +965,16 @@ instance Binary IfaceInst where
                orph <- get bh
                return (IfaceInst cls tys dfun flag orph)
 
+instance Binary IfaceFamInst where
+    put_ bh (IfaceFamInst fam tys tycon) = do
+           put_ bh fam
+           put_ bh tys
+           put_ bh tycon
+    get bh = do fam   <- get bh
+               tys   <- get bh
+               tycon <- get bh
+               return (IfaceFamInst fam tys tycon)
+
 instance Binary OverlapFlag where
     put_ bh NoOverlap  = putByte bh 0
     put_ bh OverlapOk  = putByte bh 1
@@ -983,15 +987,19 @@ instance Binary OverlapFlag where
 
 instance Binary IfaceConDecls where
     put_ bh IfAbstractTyCon = putByte bh 0
-    put_ bh (IfDataTyCon cs) = do { putByte bh 1
+    put_ bh IfOpenDataTyCon = putByte bh 1
+    put_ bh IfOpenNewTyCon = putByte bh 2
+    put_ bh (IfDataTyCon cs) = do { putByte bh 3
                                  ; put_ bh cs }
-    put_ bh (IfNewTyCon c)  = do { putByte bh 2
+    put_ bh (IfNewTyCon c)  = do { putByte bh 4
                                  ; put_ bh c }
     get bh = do
            h <- getByte bh
            case h of
              0 -> return IfAbstractTyCon
-             1 -> do cs <- get bh
+             1 -> return IfOpenDataTyCon
+             2 -> return IfOpenNewTyCon
+             3 -> do cs <- get bh
                      return (IfDataTyCon cs)
              _ -> do aa <- get bh
                      return (IfNewTyCon aa)