Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Dario Teixeira <darioteixeira@yahoo.com>
To: "Daniel Bünzli" <daniel.buenzli@erratique.ch>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Constraining abstract type to be of a given subtype
Date: Mon, 21 Feb 2011 12:22:42 -0800 (PST)	[thread overview]
Message-ID: <878199.20657.qm@web111516.mail.gq1.yahoo.com> (raw)
In-Reply-To: <AANLkTimgHHdw1Yxo396COphLEYh3otEc_rKUrTdB7qZ0@mail.gmail.com>

Hi,

> Abstraction is about hiding type representation. Variant subtyping is
> a kind of structural subtyping and is thus about type representation.
> So constraining an abstract type to be of a given structural subtype
> seems contradictory.

Yes, you're right, I abused the term "abstract type", when I meant to
say that the type exposed by the interface was not your run-of-the-mill
concrete type but instead any type that satisfied a given constraint.
What would be the proper terminology in this case?


> The only way I see to type what you want is to make FOO.kind_t
> abstract. This doesn't ensure that the implementation of 'a kind_t is
> a subtype of Kind.t itself. However if your goal is some kind of
> phantom type constraints, it will do the job. And you can still
> require a function to convert 'a kind to Kind.t. See the code below.

Which does work quite nicely, thanks!

Cheers,
Dario



      


  reply	other threads:[~2011-02-21 20:23 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
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 [this message]
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=878199.20657.qm@web111516.mail.gq1.yahoo.com \
    --to=darioteixeira@yahoo.com \
    --cc=caml-list@inria.fr \
    --cc=daniel.buenzli@erratique.ch \
    /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