[project @ 2006-01-06 15:51:23 by simonpj]
authorsimonpj <unknown>
Fri, 6 Jan 2006 15:51:23 +0000 (15:51 +0000)
committersimonpj <unknown>
Fri, 6 Jan 2006 15:51:23 +0000 (15:51 +0000)
Eta-expand some higher-rank functions.  GHC is about to
move to *invariant* rather than *contra-variant* in function
arguments, so far as type subsumption is concerned. These
eta-expansions are simple, and allow type inference to
go through with invariance.

Data/Generics/Instances.hs
Data/Generics/Twins.hs
Data/IntMap.hs
Data/Map.hs
Data/Sequence.hs
Data/Set.hs

index 926c161..75de715 100644 (file)
@@ -279,7 +279,7 @@ instance Data a => Data [a] where
                     2 -> k (k (z (:)))
                     _ -> error "gunfold"
   dataTypeOf _ = listDataType
-  dataCast1    = gcast1
+  dataCast1 f  = gcast1 f
 
 --
 -- The gmaps are given as an illustration.
@@ -310,7 +310,7 @@ instance Data a => Data (Maybe a) where
                     2 -> k (z Just)
                     _ -> error "gunfold"
   dataTypeOf _ = maybeDataType
-  dataCast1    = gcast1
+  dataCast1 f  = gcast1 f
 
 
 ------------------------------------------------------------------------------
@@ -353,7 +353,7 @@ instance (Data a, Data b) => Data (Either a b) where
                     2 -> k (z Right)
                     _ -> error "gunfold"
   dataTypeOf _ = eitherDataType
-  dataCast2    = gcast2
+  dataCast2 f  = gcast2 f
 
 
 ------------------------------------------------------------------------------
@@ -367,7 +367,7 @@ instance (Data a, Data b) => Data (a -> b) where
   toConstr _   = error "toConstr"
   gunfold _ _  = error "gunfold"
   dataTypeOf _ = mkNorepType "Prelude.(->)"
-  dataCast2    = gcast2
+  dataCast2 f  = gcast2 f
 
 
 ------------------------------------------------------------------------------
@@ -395,7 +395,7 @@ instance (Data a, Data b) => Data (a,b) where
   gunfold k z c | constrIndex c == 1 = k (k (z (,)))
   gunfold _ _ _ = error "gunfold"
   dataTypeOf _  = tuple2DataType
-  dataCast2     = gcast2
+  dataCast2 f   = gcast2 f
 
 
 ------------------------------------------------------------------------------
index dcc01aa..eed4ab6 100644 (file)
@@ -234,15 +234,13 @@ couples of immediate subterms from the two given input terms.)
 
 geq x y = geq' x y
   where
-    geq' :: forall a b. (Data a, Data b) => a -> b -> Bool
+    geq' :: GenericQ (GenericQ Bool)
     geq' x y =     (toConstr x == toConstr y)
                 && and (gzipWithQ geq' x y)
 
 
 -- | Generic zip controlled by a function with type-specific branches
-gzip :: (forall a b. (Data a, Data b) => a -> b -> Maybe b)
-     -> (forall a b. (Data a, Data b) => a -> b -> Maybe b)
-
+gzip :: GenericQ (GenericM Maybe) -> GenericQ (GenericM Maybe)
 -- See testsuite/.../Generics/gzip.hs for an illustration
 gzip f x y = 
   f x y
index d5fc9e7..1606413 100644 (file)
@@ -236,7 +236,7 @@ instance Data a => Data (IntMap a) where
   toConstr _    = error "toConstr"
   gunfold _ _   = error "gunfold"
   dataTypeOf _  = mkNorepType "Data.IntMap.IntMap"
-  dataCast1      = gcast1
+  dataCast1 f   = gcast1 f
 
 #endif
 
index beddb7b..d88ceb5 100644 (file)
@@ -216,7 +216,7 @@ instance (Data k, Data a, Ord k) => Data (Map k a) where
   toConstr _     = error "toConstr"
   gunfold _ _    = error "gunfold"
   dataTypeOf _   = mkNorepType "Data.Map.Map"
-  dataCast2      = gcast2
+  dataCast2 f    = gcast2 f
 
 #endif
 
index d072a28..3d38011 100644 (file)
@@ -178,7 +178,7 @@ instance Data a => Data (Seq a) where
 
        dataTypeOf _    = seqDataType
 
-       dataCast1       = gcast1
+       dataCast1 f     = gcast1 f
 
 emptyConstr = mkConstr seqDataType "empty" [] Prefix
 consConstr  = mkConstr seqDataType "<|" [] Infix
index f0994e5..13dff75 100644 (file)
@@ -171,7 +171,7 @@ instance (Data a, Ord a) => Data (Set a) where
   toConstr _     = error "toConstr"
   gunfold _ _    = error "gunfold"
   dataTypeOf _   = mkNorepType "Data.Set.Set"
-  dataCast1      = gcast1
+  dataCast1 f    = gcast1 f
 
 #endif