From: "Milan Stanojević" <milanst@gmail.com>
To: Markus Mottl <markus.mottl@gmail.com>
Cc: Caml List <caml-list@inria.fr>
Subject: Re: [Caml-list] an issue with coercing private types
Date: Wed, 8 May 2013 22:26:30 -0400 [thread overview]
Message-ID: <CAKR7PS_AwYyyZ9skrUj+e4yLsUm3YGVwGPGVEFqKt11b+V65jQ@mail.gmail.com> (raw)
In-Reply-To: <CAP_800o6JmWcrKP7j+6nRAiSXGYbZjBQNWwFDryCu2Z-V_H2Mg@mail.gmail.com>
Right, it seems (a : t1 :> t2) is actually a different operator that,
as you said, should I always work.
I was pointed to
http://caml.inria.fr/pub/docs/manual-ocaml/expr.html#toc53
which explains this is some detail (and I should have searched harder
it in the first place)
Thanks everyone!
On Wed, May 8, 2013 at 8:57 PM, Markus Mottl <markus.mottl@gmail.com> wrote:
> On Wed, May 8, 2013 at 7:34 PM, Milan Stanojević <milanst@gmail.com> wrote:
>> but this compiles fine
>> let to_int a = (a : 'a Foo.t :> int)
>
> This seems like the preferred solution and should always work, because
> it enforces that "a" has a coercible type (rather than e.g. a mere
> type variable) by the time type inference reaches the coercion
> operator. Otherwise it may depend on the order in which the type of
> sub-terms is inferred whether coercion will work.
>
>> and gives me the right type.
>>
>> What is wrong with the first version of [to_int]? Is this a bug in the
>> compiler? I'm using ocaml 4.0.1
>>
>> I also tried this with Foo.t that doesn't have phantom type variable
>> and in that case both versions of [to_int] work.
>
> I'm actually surprised that removing the phantom type variable makes a
> difference in that respect. I guess this just shows how unpredictable
> the order of type inference can be, hence the need for proper type
> annotations with coercions.
>
> Regards,
> Markus
>
> --
> Markus Mottl http://www.ocaml.info markus.mottl@gmail.com
next prev parent reply other threads:[~2013-05-09 2:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-08 23:34 Milan Stanojević
2013-05-09 0:57 ` Markus Mottl
2013-05-09 2:26 ` Milan Stanojević [this message]
2013-05-09 3:53 ` Jacques Garrigue
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=CAKR7PS_AwYyyZ9skrUj+e4yLsUm3YGVwGPGVEFqKt11b+V65jQ@mail.gmail.com \
--to=milanst@gmail.com \
--cc=caml-list@inria.fr \
--cc=markus.mottl@gmail.com \
/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