.p
[mTask.git] / gCons.icl
index fff9450..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
@@ -21,6 +21,7 @@ consName{|FIELD|}  f   (FIELD x)  = f x
 consName{|Int|}        i = toString i
 consName{|Bool|}       b = toString b
 consName{|Char|}       c = toString c
+consName{|String|}     s = s
 consName{|(->)|}   f g x = g (x undef)
 
 generic consIndex a :: a -> Int
@@ -33,3 +34,30 @@ consIndex{|OBJECT|} f (OBJECT x) = f x
 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]