Remove unnecessary Data/Dynamic.hs-boot
[ghc-base.git] / Data / Generics / Instances.hs
index 293b1e1..0745b05 100644 (file)
@@ -6,7 +6,7 @@
 -- 
 -- Maintainer  :  libraries@haskell.org
 -- Stability   :  experimental
--- Portability :  non-portable
+-- Portability :  non-portable (uses Data.Generics.Basics)
 --
 -- \"Scrap your boilerplate\" --- Generic programming in Haskell 
 -- See <http://www.cs.vu.nl/boilerplate/>. The present module
@@ -15,9 +15,7 @@
 --
 -----------------------------------------------------------------------------
 
-module Data.Generics.Instances 
-
-where
+module Data.Generics.Instances where
 
 
 ------------------------------------------------------------------------------
@@ -32,22 +30,21 @@ import Data.Typeable
 import Data.Int              -- So we can give Data instance for Int8, ...
 import Data.Word             -- So we can give Data instance for Word8, ...
 import GHC.Real( Ratio(..) ) -- So we can give Data instance for Ratio
-import GHC.IOBase           -- So we can give Data instance for IO, Handle
-import GHC.Ptr              -- So we can give Data instance for Ptr
-import GHC.ForeignPtr       -- So we can give Data instance for ForeignPtr
-import GHC.Stable           -- So we can give Data instance for StablePtr
-import GHC.ST               -- So we can give Data instance for ST
-import GHC.Conc                     -- So we can give Data instance for MVar & Co.
-import GHC.Arr              -- So we can give Data instance for Array
+import GHC.IOBase            -- So we can give Data instance for IO, Handle
+import GHC.Ptr               -- So we can give Data instance for Ptr
+import GHC.ForeignPtr        -- So we can give Data instance for ForeignPtr
+import GHC.Stable            -- So we can give Data instance for StablePtr
+import GHC.ST                -- So we can give Data instance for ST
+import GHC.Conc              -- So we can give Data instance for MVar & Co.
+import GHC.Arr               -- So we can give Data instance for Array
 
 #include "Typeable.h"
 
 
 ------------------------------------------------------------------------------
 --
---     Instances of the Data class for Prelude-like types.
---     We define top-level definitions for representations.
+--      Instances of the Data class for Prelude-like types.
+--      We define top-level definitions for representations.
 --
 ------------------------------------------------------------------------------
 
@@ -279,7 +276,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 +307,7 @@ instance Data a => Data (Maybe a) where
                     2 -> k (z Just)
                     _ -> error "gunfold"
   dataTypeOf _ = maybeDataType
-  dataCast1    = gcast1
+  dataCast1 f  = gcast1 f
 
 
 ------------------------------------------------------------------------------
@@ -353,7 +350,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 +364,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
 
 
 ------------------------------------------------------------------------------
@@ -377,8 +374,8 @@ tuple0Constr = mkConstr tuple0DataType "()" [] Prefix
 tuple0DataType = mkDataType "Prelude.()" [tuple0Constr]
 
 instance Data () where
-  toConstr _    = tuple0Constr
-  gunfold k z c | constrIndex c == 1 = z ()  
+  toConstr ()   = tuple0Constr
+  gunfold k z c | constrIndex c == 1 = z ()
   gunfold _ _ _ = error "gunfold"
   dataTypeOf _  = tuple0DataType
 
@@ -391,11 +388,11 @@ tuple2DataType = mkDataType "Prelude.(,)" [tuple2Constr]
 
 instance (Data a, Data b) => Data (a,b) where
   gfoldl f z (a,b) = z (,) `f` a `f` b
-  toConstr _    = tuple2Constr
+  toConstr (a,b) = tuple2Constr
   gunfold k z c | constrIndex c == 1 = k (k (z (,)))
   gunfold _ _ _ = error "gunfold"
   dataTypeOf _  = tuple2DataType
-  dataCast2     = gcast2
+  dataCast2 f   = gcast2 f
 
 
 ------------------------------------------------------------------------------
@@ -406,7 +403,7 @@ tuple3DataType = mkDataType "Prelude.(,)" [tuple3Constr]
 
 instance (Data a, Data b, Data c) => Data (a,b,c) where
   gfoldl f z (a,b,c) = z (,,) `f` a `f` b `f` c
-  toConstr _    = tuple3Constr
+  toConstr (a,b,c) = tuple3Constr
   gunfold k z c | constrIndex c == 1 = k (k (k (z (,,))))
   gunfold _ _ _ = error "gunfold"
   dataTypeOf _  = tuple3DataType
@@ -421,7 +418,7 @@ tuple4DataType = mkDataType "Prelude.(,,,)" [tuple4Constr]
 instance (Data a, Data b, Data c, Data d)
          => Data (a,b,c,d) where
   gfoldl f z (a,b,c,d) = z (,,,) `f` a `f` b `f` c `f` d
-  toConstr _ = tuple4Constr
+  toConstr (a,b,c,d) = tuple4Constr
   gunfold k z c = case constrIndex c of
                     1 -> k (k (k (k (z (,,,)))))
                     _ -> error "gunfold"
@@ -437,7 +434,7 @@ tuple5DataType = mkDataType "Prelude.(,,,,)" [tuple5Constr]
 instance (Data a, Data b, Data c, Data d, Data e)
          => Data (a,b,c,d,e) where
   gfoldl f z (a,b,c,d,e) = z (,,,,) `f` a `f` b `f` c `f` d `f` e
-  toConstr _ = tuple5Constr
+  toConstr (a,b,c,d,e) = tuple5Constr
   gunfold k z c = case constrIndex c of
                     1 -> k (k (k (k (k (z (,,,,))))))
                     _ -> error "gunfold"
@@ -453,7 +450,7 @@ tuple6DataType = mkDataType "Prelude.(,,,,,)" [tuple6Constr]
 instance (Data a, Data b, Data c, Data d, Data e, Data f)
          => Data (a,b,c,d,e,f) where
   gfoldl f z (a,b,c,d,e,f') = z (,,,,,) `f` a `f` b `f` c `f` d `f` e `f` f'
-  toConstr _ = tuple6Constr
+  toConstr (a,b,c,d,e,f) = tuple6Constr
   gunfold k z c = case constrIndex c of
                     1 -> k (k (k (k (k (k (z (,,,,,)))))))
                     _ -> error "gunfold"
@@ -470,7 +467,7 @@ instance (Data a, Data b, Data c, Data d, Data e, Data f, Data g)
          => Data (a,b,c,d,e,f,g) where
   gfoldl f z (a,b,c,d,e,f',g) =
     z (,,,,,,) `f` a `f` b `f` c `f` d `f` e `f` f' `f` g
-  toConstr _ = tuple7Constr
+  toConstr  (a,b,c,d,e,f,g) = tuple7Constr
   gunfold k z c = case constrIndex c of
                     1 -> k (k (k (k (k (k (k (z (,,,,,,))))))))
                     _ -> error "gunfold"