Browse thread
cyclic types
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | skaller <skaller@u...> |
| Subject: | Re: [Caml-list] cyclic types |
On Sun, 2005-01-30 at 04:12, brogoff wrote: > On Sat, 29 Jan 2005, Remi Vanicat wrote: > > On Sat, 29 Jan 2005 14:15:43 +0200, Radu Grigore <radugrigore@gmail.com> wrote: > > > Why are cyclic types forbidden? > > > > > > I was forced to use the definition: > > > type forest = Forest of forest StringMap.t | Empty > > > where I would have rather used > > > type forest = forest StringMap.t > > > The error is: > > > The type abbreviation tree is cyclic > > > > You can use the -rectypes of the ocaml compiler or toplevel to allow > > cyclic type. > > This comes up relatively frequently, and it is known that having -rectypes > as the default is not a good idea. However, wouldn't explicit typing of > this case sidestep the known problems and eliminate the need for a > -rectypes option here? Do you mean something like: type rec forest = forest StringMap.t where the 'rec' means 'just this type is meant to be cyclic' (and treat that type as if -rectypes had been given)? [or types, if there is an 'and' given] -- John Skaller, mailto:skaller@users.sf.net voice: 061-2-9660-0850, snail: PO BOX 401 Glebe NSW 2037 Australia Checkout the Felix programming language http://felix.sf.net