.p
[mTask.git] / gCons.icl
index 3446116..e34909a 100644 (file)
--- a/gCons.icl
+++ b/gCons.icl
@@ -7,7 +7,7 @@ implementation module gCons
        ARDSL project
 */
 
-import StdEnv, StdGeneric
+import StdEnv, StdGeneric, GenBimap, _SystemStrictLists
 
 generic consName a :: a -> String
 consName{|CONS of {gcd_name}|} f x = gcd_name
@@ -35,3 +35,29 @@ consIndex{|Int|} i = i
 consIndex{|Bool|} b = if b 1 0
 consIndex{|Char|} c = toInt c
 consIndex{|String|} _ = 0
+
+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]