modularize
[mTask.git] / Generics / gCons.icl
index fc4debc..6f0ceb3 100644 (file)
@@ -8,6 +8,7 @@ implementation module Generics.gCons
 */
 
 import StdEnv, StdGeneric, GenBimap, _SystemStrictLists
+import Data.List
 
 generic consName a :: a -> String
 consName{|CONS of {gcd_name}|} f x = gcd_name
@@ -23,6 +24,11 @@ consName{|Bool|}       b = toString b
 consName{|Char|}       c = toString c
 consName{|String|}     s = s
 consName{|[]|} _ _ = "[]"
+consName{|()|} _ = "()"
+consName{|(,)|} _ _ _ = "(,)"
+consName{|(,,)|}  _ _ _ _ = "(,,)"
+consName{|(,,,)|}  _ _ _ _ _ = "(,,,)"
+consName{|(,,,,)|}  _ _ _ _ _ _ = "(,,,,)"
 consName{|(->)|}   f g x = g (x undef)
 
 generic consIndex a :: a -> Int
@@ -37,6 +43,11 @@ consIndex{|Bool|} b = if b 1 0
 consIndex{|Char|} c = toInt c
 consIndex{|String|} _ = 0
 consIndex{|[]|} _ _ = 0
+consIndex{|()|} _ = 0
+consIndex{|(,)|} _ _ _ = 0
+consIndex{|(,,)|}  _ _ _ _ = 0
+consIndex{|(,,,)|}  _ _ _ _ _ = 0
+consIndex{|(,,,,)|}  _ _ _ _ _ _ = 0
 
 generic conses a :: [a]
 conses{|CONS|} f = [CONS (hd f)]
@@ -55,7 +66,11 @@ conses{|[]|} _ = [[ ]]
 conses{|[!]|} _ = [[!]]
 conses{|[ !]|} _ = [[ !]]
 conses{|[!!]|} _ = [[!!]]
+conses{|()|} = [()]
+conses{|(,)|} f g = zip2 f g
+conses{|(,,)|}  f g h = zip3 f g h
+conses{|(,,,)|}  f g h i = zip4 f g h i
+conses{|(,,,,)|}  f g h i j = zip5 f g h i j
 conses{|{}|} _ = [{}]
 conses{|{!}|} _ = [{!}]
-conses{|()|} = [()]
 conses{|(->)|} _ _ = [const undef]