caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
To: vanicat@debian.org
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Re: polymorphic variants and promotion
Date: Wed, 20 Feb 2008 14:01:27 +0900 (JST)	[thread overview]
Message-ID: <20080220.140127.238245617.garrigue@math.nagoya-u.ac.jp> (raw)
In-Reply-To: <871w796rj7.dlv@maison.homelinux.org>

From: Remi Vanicat <vanicat@debian.org>
> Well, you have to explicitly coerce :
> 
> let h a = function                                              
>       | [] -> g a                                                 
>       | xs -> (List.fold_left f a xs : [ `A of _ ] :> [> `A of _ | `B of _ ]) ;;
> 
> What I don't understand is why this :
> 
> let h a = function                                              
>       | [] -> g a                                                 
>       | xs -> (List.fold_left f a xs :> [> `A of _ | `B of _ ]) ;;
> 
> do not work ? I understood that we need to explicitly coerce, but the 
> [ `A of _ ] is just the information the compiler will find by itself,
> why must we give it to it again ?

Because we cannot always be sure that the compiler will infer it at
the right time. I.e., we would end up with some programs having
different typing behaviours when the above application is inferred as
[`A of _] and when a less precise type is inferred, which could cause
unification errors somewhere else...

We are currently considering allowing the above kind of abbreviation
when both the source and target are ground types (i.e. do not contain
type variables). But this would not include the above example.

Jacques Garrigue


      reply	other threads:[~2008-02-20  5:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-19 10:23 Johannes Kanig
2008-02-19 12:38 ` [Caml-list] " Julien Signoles
2008-02-19 13:37   ` Keiko Nakata
2008-02-19 22:26     ` Christophe Raffalli
2008-02-20  4:50       ` Jacques Garrigue
2008-02-19 12:48 ` Remi Vanicat
2008-02-20  5:01   ` Jacques Garrigue [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=20080220.140127.238245617.garrigue@math.nagoya-u.ac.jp \
    --to=garrigue@math.nagoya-u.ac.jp \
    --cc=caml-list@inria.fr \
    --cc=vanicat@debian.org \
    /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).