From: "Olivier Andrieu" <oandrieu@nerim.net>
To: micha <micha-1@fantasymail.de>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] phantom type thing question
Date: Thu, 1 Mar 2007 18:03:44 +0100 [thread overview]
Message-ID: <95513600703010903n18ae6a7bo34c84eeca04fefdd@mail.gmail.com> (raw)
In-Reply-To: <20070301174026.5b1c2ba2@localhost>
On 3/1/07, micha <micha-1@fantasymail.de> wrote:
> Am Thu, 1 Mar 2007 14:47:47 +0100
> schrieb "Olivier Andrieu" <oandrieu@gmail.com>:
>
> > On 3/1/07, micha <micha-1@fantasymail.de> wrote:
> > >
> > if you want subtyping, you'll need to add a variance annotation to
> > your type parameter. Otherwise since your type sym is abstract, you'll
> > get no subtyping at all. In this case you probably want a
> > contravariant type parameter:
> >
> > type -'a sym
>
> o.k., but after reading section 6.8.1 of the manual I don't see why it
> needs to be -'a and not +'a
>
>
> > that should be:
> > val get_image_width : [> xpm] sym -> int
your parameter encodes some "capabilities": you want the function
get_image_width to accept values that have the tag `xpm and possibly
more tags, hence the [> ] in the type of the function.
In other words, you want the type xpm sym to be a subtype of
[xpm|`xpm8] sym (for instance), so that get_image_width accept boths.
Since [xpm|`xpm8] is a subtype of xpm sym (the other way around), that
means the parameter needs to be contravariant.
next prev parent reply other threads:[~2007-03-01 17:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-01 9:46 micha
[not found] ` <95513600703010547t1f098d80p7bbff2f2c85d79a5@mail.gmail.com>
2007-03-01 13:49 ` [Caml-list] " Olivier Andrieu
2007-03-01 16:40 ` micha
2007-03-01 17:03 ` Olivier Andrieu [this message]
2007-03-01 20:01 ` micha
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=95513600703010903n18ae6a7bo34c84eeca04fefdd@mail.gmail.com \
--to=oandrieu@nerim.net \
--cc=caml-list@inria.fr \
--cc=micha-1@fantasymail.de \
/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).