domain package now permits indirect recursion with these type constructors: *, ->, ++, **, u
authorhuffman
Fri, 11 Mar 2005 00:43:52 +0100
changeset 15601 2de79f493856
parent 15600 a59f07556a8d
child 15602 83c0bf275b0f
domain package now permits indirect recursion with these type constructors: *, ->, ++, **, u
src/HOLCF/domain/extender.ML
--- a/src/HOLCF/domain/extender.ML	Thu Mar 10 20:22:45 2005 +0100
+++ b/src/HOLCF/domain/extender.ML	Fri Mar 11 00:43:52 2005 +0100
@@ -66,6 +66,7 @@
 	|   rm_sorts (Type(s,ts)) = Type(s,remove_sorts ts)
 	|   rm_sorts (TVar(s,_))  = TVar(s,[])
 	and remove_sorts l = map rm_sorts l;
+	val indirect_ok = ["*","Cfun.->","Ssum.++","Sprod.**","Up.u"]
 	fun analyse indirect (TFree(v,s))  = (case assoc_string(tvars,v) of 
 		    NONE => error ("Free type variable " ^ quote v ^ " on rhs.")
 	          | SOME sort => if eq_set_string (s,defaultS) orelse
@@ -74,7 +75,9 @@
 				 else error ("Inconsistent sort constraint" ^
 				             " for type variable " ^ quote v))
         |   analyse indirect (t as Type(s,typl)) = (case assoc_string(dtnvs,s)of
-		NONE          => Type(s,map (analyse true) typl)
+		NONE          => if exists (fn x => x = s) indirect_ok
+				 then Type(s,map (analyse false) typl)
+				 else Type(s,map (analyse true) typl)
 	      | SOME typevars => if indirect 
                            then error ("Indirect recursion of type " ^ 
 				        quote (string_of_typ sg t))