.p
[mTask.git] / gCons.icl
index 3f13a7d..e34909a 100644 (file)
--- a/gCons.icl
+++ b/gCons.icl
@@ -36,24 +36,28 @@ consIndex{|Bool|} b = if b 1 0
 consIndex{|Char|} c = toInt c
 consIndex{|String|} _ = 0
 
-generic conses a :: [a]
-conses{|CONS|} f = map CONS f
-conses{|UNIT|} = [UNIT]
-conses{|PAIR|} f g = []
-conses{|EITHER|} f g = map LEFT f ++ map RIGHT g
-conses{|OBJECT|} f = map OBJECT f
-conses{|RECORD|} f = map RECORD f
-conses{|FIELD|} f = map FIELD f
-conses{|Int|} = [0]
-conses{|Bool|} = [True]
-conses{|Char|} = ['\0']
-conses{|Real|} = [0.0]
-conses{|String|} = [""]
-conses{|[]|} _ = [[ ]]
-conses{|[!]|} _ = [[!]]
-conses{|[ !]|} _ = [[ !]]
-conses{|[!!]|} _ = [[!!]]
-conses{|{}|} _ = [{}]
-conses{|{!}|} _ = [{!}]
-conses{|()|} = [()]
+conses :: [a] | gconses{|*|} a
+conses = gconses{|*|} True
 
+generic gconses a :: Bool -> [a]
+gconses{|CONS|} f True = map CONS (f False)
+gconses{|CONS|} f b = [CONS (hd (f b))]
+gconses{|UNIT|} _ = [UNIT]
+gconses{|PAIR|} f g _ = []
+gconses{|EITHER|} f g b = map LEFT (f b) ++ map RIGHT (g b)
+gconses{|OBJECT|} f b = map OBJECT (f b)
+gconses{|RECORD|} f b = map RECORD (f b)
+gconses{|FIELD|} f b = map FIELD (f b)
+gconses{|Int|} _ = [0]
+gconses{|Bool|} _ = [True]
+gconses{|Char|} _ = ['\0']
+gconses{|Real|} _ = [0.0]
+gconses{|String|} _ = [""]
+gconses{|[]|} _ _ = [[ ]]
+gconses{|[!]|} _ _ = [[!]]
+gconses{|[ !]|} _ _ = [[ !]]
+gconses{|[!!]|} _ _ = [[!!]]
+gconses{|{}|} _ _ = [{}]
+gconses{|{!}|} _ _ = [{!}]
+gconses{|()|} _ = [()]
+gconses{|(->)|} _ _ _ = [const undef]