[bitc-dev] Bitc -> Polymorphic
David Hopwood
david.nospam.hopwood at blueyonder.co.uk
Mon Jan 31 14:56:52 EST 2005
Jørgen Hermanrud Fjeld wrote:
> The O'Caml language permits recursive data definitions, when the option
> -rectypes is given. There was/is just a discussion about this on the
> O'Caml mailing list, and there are no theoretical problems with
> recursive data definitions, but the type inference engine infers weird
> types for cases that otherwise would be discovered as errors,
> and then even weirder error messages appear when using the functions.
>
> (* with -rectypes *)
> type t = t option
>
> (* without -rectypes *)
> type t = Some of t | None
>
> (* Sample session from interactive toplevel for O'Caml *)
> #ocamli -rectypes
> Objective Caml version 3.08.2
>
> # type t = t option;;
> type t = t option
> # let (x:t) = None;;
> val x : t = None
> # let (x:t) = Some (Some x);;
> val x : t = Some (Some None)
I don't see what is weird about this, at least from the given example.
It works as I would expect from recursive types in Haskell and other
languages.
--
David Hopwood <david.nospam.hopwood at blueyonder.co.uk>
More information about the bitc-dev
mailing list