ue
[clean-tests.git] / test3.icl
diff --git a/test3.icl b/test3.icl
new file mode 100644 (file)
index 0000000..0b6455a
--- /dev/null
+++ b/test3.icl
@@ -0,0 +1,33 @@
+module test
+
+import Data.Func
+import StdEnv, StdGeneric
+
+:: IsR a = IsR Bool | IsROnzin a
+unIsR (IsR b) = b
+generic gIsRecursive a :: [String] -> IsR a
+gIsRecursive{|Bool|} _ = IsR False
+gIsRecursive{|Char|} _ = IsR False
+gIsRecursive{|Real|} _ = IsR False
+gIsRecursive{|Int|} _ = IsR False
+gIsRecursive{|{}|} a m = IsR $ unIsR (a m)
+gIsRecursive{|{!}|} a m = IsR $ unIsR (a m)
+gIsRecursive{|{!!}|} a m = IsR $ unIsR (a m)
+gIsRecursive{|UNIT|} _ = IsR False
+gIsRecursive{|EITHER|} l r m = IsR $ unIsR (l m) || unIsR (r m)
+gIsRecursive{|PAIR|} l r m = IsR $ unIsR (l m) || unIsR (r m)
+gIsRecursive{|CONS|} x m = IsR $ unIsR (x m)
+gIsRecursive{|FIELD|} x m = IsR $ unIsR (x m)
+gIsRecursive{|RECORD of grd|} x m
+       | isMember grd.grd_name m = IsR True
+       = IsR $ unIsR (x [grd.grd_name:m])
+gIsRecursive{|OBJECT of gtd|} x m
+       | isMember gtd.gtd_name m = IsR True
+       = IsR $ unIsR (x [gtd.gtd_name:m])
+
+:: R = {f1 :: Int, f2 :: Bool, f3 :: [R]}
+derive gIsRecursive [], R
+
+//Start :: IsR [Int]
+Start :: IsR R
+Start = gIsRecursive{|*|} []