[bitc-dev] Bitc -> Polymorphic
David Hopwood
david.nospam.hopwood at blueyonder.co.uk
Mon Jan 31 22:31:45 EST 2005
Jørgen Hermanrud Fjeld wrote:
> On Mon, Jan 31, 2005 at 07:56:52PM +0000, David Hopwood wrote:
>
>>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.
>
> The sample only illustrated how O'Caml does recursive types, for the record.
> You can find the example of weird recursive types in the O'Caml
> mailing list "http://caml.inria.fr/archives/200501/msg00337.html" in a post by Xavier.
Perhaps a warning message could be output, e.g.:
# let f x = x :: x
val f : ('a list as 'a) -> 'a list = <fun>
Warning: check whether this type was intended to be recursive.
# f [1;2;3];;
Characters 3-4:
f [1;2;3];;
^
This expression has type int but is here used with type 'a list as 'a
but if this is the only problem, I don't think it's serious. Note that
the type ('a list as 'a) is perfectly valid:
# f [];;
- : ('a list as 'a) list = [[]]
--
David Hopwood <david.nospam.hopwood at blueyonder.co.uk>
More information about the bitc-dev
mailing list