From: Guillaume Yziquel <guillaume.yziquel@citycable.ch>
To: Dario Teixeira <darioteixeira@yahoo.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Constraining abstract type to be of a given subtype
Date: Mon, 21 Feb 2011 18:07:03 +0100 [thread overview]
Message-ID: <20110221170702.GJ25151@localhost> (raw)
In-Reply-To: <241708.48122.qm@web111501.mail.gq1.yahoo.com>
Le Monday 21 Feb 2011 à 07:56:43 (-0800), Dario Teixeira a écrit :
> Hi,
>
> In a signature FOO, I'm trying to constrain an abstract type kind_t to be a
> subtype of Kind.t (please see code below). However, I get a compiler error
> when I declare an actual struct Foo1 which supposedly obeys signature FOO:
>
> Type declarations do not match:
> type 'a kind_t = [ `A ]
> is not included in
> type 'a kind_t = 'a constraint 'a = [< Kind.t ]
>
>
> Any hints as to what is wrong here? Thanks in advance for your help!
Well, I clearly see to what 'a is bound to in
type 'a kind_t = 'a constraint 'a = [< Kind.t ]
but I do not see to what 'a is bound to in
type 'a kind_t = [ `A ]
As 'a kind_t is declared to be 'a in the first type declaration, it
should also be the case in the second type declaration. However, 'a is a
phantom type parameter there.
> Best regards,
> Dario Teixeira
But I think that you will not be able to do such type narrowing in a
module interface / module interface fashion. At least not without an
indication of covariance or contravariance. And even then, I'm not sure
if that is possible.
--
Guillaume Yziquel
next prev parent reply other threads:[~2011-02-21 17:09 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-21 15:56 Dario Teixeira
2011-02-21 17:07 ` Guillaume Yziquel [this message]
2011-02-21 18:42 ` Dario Teixeira
2011-02-21 19:26 ` Guillaume Yziquel
2011-02-21 19:39 ` Daniel Bünzli
2011-02-21 20:22 ` Dario Teixeira
2011-02-21 20:59 ` Daniel Bünzli
2011-02-21 21:31 ` Daniel Bünzli
2011-02-21 21:49 ` Daniel Bünzli
2011-02-22 16:15 ` Dario Teixeira
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=20110221170702.GJ25151@localhost \
--to=guillaume.yziquel@citycable.ch \
--cc=caml-list@inria.fr \
--cc=darioteixeira@yahoo.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