[project @ 2003-12-06 17:48:49 by ralf]
authorralf <unknown>
Sat, 6 Dec 2003 17:48:49 +0000 (17:48 +0000)
committerralf <unknown>
Sat, 6 Dec 2003 17:48:49 +0000 (17:48 +0000)
Added Data instances for triples and quadruples.

Data/Generics/Basics.hs

index 16b6a32..7e7cf7c 100644 (file)
@@ -557,6 +557,7 @@ instance Data a => Data (Maybe a) where
                    2 -> Just undefined
   dataTypeOf _ = maybeDataType
 
+
 --
 -- Yet another polymorphic datatype constructor.
 -- No surprises.
@@ -572,12 +573,38 @@ instance (Data a, Data b) => Data (a,b) where
                    1 -> (undefined,undefined)
   dataTypeOf _ = productDataType
 
+
 --
 -- Yet another polymorphic datatype constructor.
 -- No surprises.
 --
+tripleConstr = mkConstr 1 "(,,)" Infix
+tripleDataType = mkDataType [tripleConstr]
+
+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 _ = tripleConstr
+  fromConstr c = case conIndex c of
+                   1 -> (undefined,undefined,undefined)
+  dataTypeOf _ = tripleDataType
+quadrupleConstr = mkConstr 1 "(,,,)" Infix
+quadrupleDataType = mkDataType [quadrupleConstr]
+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 _ = quadrupleConstr
+  fromConstr c = case conIndex c of
+                   1 -> (undefined,undefined,undefined,undefined)
+  dataTypeOf _ = quadrupleDataType
 
 
+--
+-- Yet another polymorphic datatype constructor.
+-- No surprises.
+--
+
 leftConstr     = mkConstr 1 "Left"  Prefix
 rightConstr    = mkConstr 2 "Right" Prefix
 eitherDataType = mkDataType [leftConstr,rightConstr]