From: Markus Mottl <markus.mottl@gmail.com>
To: Christophe Raffalli <christophe@raffalli.eu>
Cc: "caml-list@inria.fr" <caml-list@inria.fr>
Subject: Re: [Caml-list] problem with generalisation
Date: Sat, 23 Sep 2017 17:04:06 -0400 [thread overview]
Message-ID: <CAP_800omXHZcOpeeOdS+xXwFPH3ficUQLDEf+XnRrOTEOjS57A@mail.gmail.com> (raw)
In-Reply-To: <20170923174705.wkdryyzkixlroqdw@delli7.univ-savoie.fr>
Hi Christophe,
the following definition of "promote" works for me:
let promote (type a) (f : a -> unit) : a iter = { f }
It seems that making the type variable locally existential within the
body of "promote" helps the compiler make the correct inference.
Using a universally quantified 'a instead won't work.
Regards,
Markus
On Sat, Sep 23, 2017 at 1:47 PM, Christophe Raffalli
<christophe@raffalli.eu> wrote:
> Hello,
>
> I am blocked by this case not working (I reported on Mantis ...
> https://caml.inria.fr/mantis/view.php?id=7636)
>
> Any hint on how to make it works, apart fomr Obj.magic ?
>
> I can not change the types, they come from a functor.
>
> ====================================================
> type ('a, 'b) elt = 'a
>
> type 'a iter = { f : 'b.('a, 'b) elt -> unit }
>
> let promote f : 'a -> unit =
> let f : 'b.('a, 'b) elt -> unit = fun x -> f x in
> { f }
> ====================================================
>
> Cheers,
> Christophe
--
Markus Mottl http://www.ocaml.info markus.mottl@gmail.com
prev parent reply other threads:[~2017-09-23 21:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-23 17:47 Christophe Raffalli
2017-09-23 20:40 ` Damien Guichard
2017-09-23 21:04 ` Markus Mottl [this message]
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=CAP_800omXHZcOpeeOdS+xXwFPH3ficUQLDEf+XnRrOTEOjS57A@mail.gmail.com \
--to=markus.mottl@gmail.com \
--cc=caml-list@inria.fr \
--cc=christophe@raffalli.eu \
/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