Version franÁaise
Home ††† About ††† Download ††† Resources ††† Contact us †††
Browse thread
typing problem with sexplib and mutually recursive polymorphic types
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Till Varoquaux <till.varoquaux@g...>
Subject: Re: [Caml-list] typing problem with sexplib and mutually recursive polymorphic types
This is a quick overview of my current understanding. Corrections by
higher authorities are welcome:

Optional type declarations in ocaml only enable to restrict given
types (not to generalize them). Although it enables better error
reporting it does not allow us to compile anything that would compile
without. This can be seen as additional constraints to enforce during
typing eg:

let f : ('a -> 'a -> 'a) = (+) 1

is fine because we have added the constraint "the return type must be
the same as both the argument types". If we were type-checking this as
'a.'a->'a->'a this would fail.

There's a caveat for formats

let f : (_,_,_) format = "%s"

and object types:

let f (v : < pol:'a.'a -> _;..> ) =
  v#pol 4;
  v#pol ()

The ability to generalize type by hand is being explored by didier
remy in MLF. I do not know how far this is from going in OCaml (if
ever).

Till



On Wed, Mar 11, 2009 at 12:43 PM, Markus Mottl <markus.mottl@gmail.com> wrote:
> On Wed, Mar 11, 2009 at 12:16, Damien Doligez <damien.doligez@inria.fr> wrote:
>> That is not quite true any more.  For example, I changed the
>> type-checker a few years ago to start with the user-provided type
>> when typing a let rec, in order to be able to debug my large
>> recursive definitions.  Note that I didn't do that from scrach,
>> I used an infrastructure that was already present for seeding the
>> type inference in some cases.  IIRC, it is there for some object-
>> oriented reason.
>
> Interesting, this change seems to have passed unobserved by me and is
> certainly a great debugging aid.  Does this mean that eventually
> polymorphic recursion might be supported by OCaml?  What's still
> missing for that feature?
>
> Regards,
> Markus
>
> --
> Markus Mottl        http://www.ocaml.info        markus.mottl@gmail.com
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>