caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Vincent Aravantinos <vincent.aravantinos@gmail.com>
To: Jake Donham <jake@donham.org>
Cc: Marc de Falco <marc@de-falco.fr>, caml-list@inria.fr
Subject: Re: [Caml-list] A strange typing error with polymorphic variants
Date: Tue, 27 Oct 2009 19:38:00 +0100	[thread overview]
Message-ID: <3EEE3582-26E5-40D9-AA3A-C33CF1B4FE50@gmail.com> (raw)
In-Reply-To: <c7e4e9f0910271124g68f2695au412b423e04828bf6@mail.gmail.com>


Le 27 oct. 09 à 19:24, Jake Donham a écrit :

> On Tue, Oct 27, 2009 at 3:28 AM, Marc de Falco <marc@de-falco.fr>  
> wrote:
>> 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.
>
> I think this is just the value restriction. The type of f is
> generalized only if the right hand side is a value (rather than an
> expression needing some computation); in your examples the one that
> fails is not a value, the others are. It looks like there is a
> relaxation to allow let bindings which are themselves values.

With the -dlambda option, the "sqrt(2.0)" version gives:
   (let
     (f/92
        (let (x/93 (caml_sqrt_float 2.0))
          (function param/94 (makemutable 0 [1: 0.0] 65a))))

whereas the "2.0" version gives:
   (let (f/96 (let (x/97 2.0) (function param/98 (makemutable 0 [1:  
0.0] 65a))))

i.e. this last version is inlined.

I thought the yping was done before (??)

V.







  reply	other threads:[~2009-10-27 18:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-27 10:28 Marc de Falco
2009-10-27 18:24 ` [Caml-list] " Jake Donham
2009-10-27 18:38   ` Vincent Aravantinos [this message]
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=3EEE3582-26E5-40D9-AA3A-C33CF1B4FE50@gmail.com \
    --to=vincent.aravantinos@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=jake@donham.org \
    --cc=marc@de-falco.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;
as well as URLs for NNTP newsgroup(s).