From: Marc de Falco <marc@de-falco.fr>
To: caml-list@inria.fr
Subject: A strange typing error with polymorphic variants
Date: Tue, 27 Oct 2009 11:28:25 +0100 [thread overview]
Message-ID: <d2c83f640910270328l75220741vc57937034dc56f8@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 829 bytes --]
Hi, I've come across a very strange error, and I'm not sure if it is
a bug or a feature.
The following code :
type 'a p = R of 'a t | E of float
and 'a t = { mutable p : 'a p; c : 'a }
let f =
let x = sqrt(2.0) in
fun () -> { c = `A; p = E 0.0 }
generates the error :
The type of this expression, unit -> _[> `A ] t,
contains type variables that cannot be generalized
but if I change the x definition to "let x = 2.0 in" then it works.
Another solution is to add a dummy parameter "let f ?(dummy=())" this works
too.
When I say that it works, I mean that the resulting type of f is
val f : unit -> [> `A ] t
I've seen that in the dev version of ocaml this error has been removed but
the type of f is still "val f : unit -> _[> `A] t" which is not the thing
that I want.
Is that an expected behavior ?
Marc
[-- Attachment #2: Type: text/html, Size: 1001 bytes --]
next reply other threads:[~2009-10-27 10:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-27 10:28 Marc de Falco [this message]
2009-10-27 18:24 ` [Caml-list] " Jake Donham
2009-10-27 18:38 ` Vincent Aravantinos
2009-10-27 19:02 ` Vincent Aravantinos
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d2c83f640910270328l75220741vc57937034dc56f8@mail.gmail.com \
--to=marc@de-falco.fr \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox