Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: bluestorm <bluestorm.dylc@gmail.com>
To: Joseph Young <ocaml@optimojoe.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Conditionals based on phantom types
Date: Tue, 3 Aug 2010 08:57:19 +0200	[thread overview]
Message-ID: <AANLkTinkO66Ps6W6q3UDnz3FWQbNhnU7MKG40CMDyK6K@mail.gmail.com> (raw)
In-Reply-To: <Pine.LNX.4.64.1008030812270.4144@myhome>

On Tue, Aug 3, 2010 at 8:15 AM, Joseph Young <ocaml@optimojoe.com> wrote:
> module Units : sig
>    type t
>    val to_feet : float -> [`Feet]*t
>    val to_meters : float -> [`Meters]*t
>    [..]
> end

With this type, the value representation of units is not abstract
anymore (and it is not very useful to have still t abstract). The user
can analyse the values you give him and access the unit member. This
is the difference with the ('a t) representation were the relation
between 'a and values is hidden outside the module.

For example, your user can write something like that, wich could be
indesirable :

let convert [ `Feet ] * Units.t -> [ `Meters ] * Units.t =
  function (`Feet, t) -> (`Meters, t)


  reply	other threads:[~2010-08-03  6:57 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-02  7:07 Joseph Young
2010-08-02  7:49 ` [Caml-list] " Lukasz Stafiniak
2010-08-02  8:02   ` bluestorm
2010-08-03  2:46     ` Joseph Young
2010-08-03  6:15       ` Joseph Young
2010-08-03  6:57         ` bluestorm [this message]
2010-08-04  2:41           ` Joseph Young
2010-08-03 15:47     ` Goswin von Brederlow
2010-08-03 15:39 ` Goswin von Brederlow

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=AANLkTinkO66Ps6W6q3UDnz3FWQbNhnU7MKG40CMDyK6K@mail.gmail.com \
    --to=bluestorm.dylc@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=ocaml@optimojoe.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