X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=gCons.icl;h=6e5aaa52d14b48efc5685f319005e369559605dc;hb=9f47008270ad2ab66d7787eb29b0f83a82a8e42e;hp=fff9450cf2154a9b70b61626d60b5d6f10de51f7;hpb=f150c433c7a55e25a4f700b7c33b0e9cbdaff81a;p=mTask.git diff --git a/gCons.icl b/gCons.icl index fff9450..6e5aaa5 100644 --- 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,8 @@ 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{|[]|} _ _ = "[]" consName{|(->)|} f g x = g (x undef) generic consIndex a :: a -> Int @@ -33,3 +35,27 @@ 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 +consIndex{|[]|} _ _ = 0 + +generic conses a :: [a] +conses{|CONS|} f = [CONS (hd 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{|(->)|} _ _ = [const undef]