Actually, the "type recursivity" is syntactic: if you wrap your recursive type in a data constructor or a record, there is no cycle in the type. Using directly 'node option' won't work since syntactically there is no data constructor to the unfold the type. We know that the option type is an ADT so we can think that this definition is correct and does not need the -rectypes flag, but the typechecker will not infer such a characteristic and decide that, by looking at the type definition, it is recursive since there is no constructor to fold and unfold the type. The only problem by redefining an option type especially for this definition is that it won't be compatible with the built-in option type. An idea to overcome this problem would be to be able to use the type redefinition : type tree =... and type node = tree option = Some of tree | None However, I don't know if it would be possible/sound, and really necessary without complexifying the language. Le 16 nov. 2015 5:43 PM, "peterfrey" a écrit : > Interestingly, this definition is accepted: > >> >> type tree = (int * 'a * 'a) option as 'a >> >> Here you are helping the type-checker because you give it a "canonical" >> representation that it can use when unifying; it no longer has to expand >> the type, potentially infinitely. I think the main point is that the type >> is isorecursive, but I'm not really an expert on the subject. >> >> with this type-checking business I sometimes have the feel being Alice in > Wonderland; its getting curiouser and curiouser ... > > The type : type node = int * tree * tree and tree = node option is, in > fact, accepted if you use the -rectypes option. > I just checked it with utop -rectypes > > I wonder if this is considered bad (dangerous) style; but there are > several things that would not work for me without this option. > > Peter Frey > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa.inria.fr/sympa/arc/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs >