caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Philippe Wang <lists@philippewang.info>
To: "Nathaniel Gray" <n8gray@gmail.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Question on writing efficient Ocaml.
Date: Sat, 6 Jan 2007 02:01:28 +0100	[thread overview]
Message-ID: <5E08B56F-D4AF-4904-ABD5-789390598F0C@philippewang.info> (raw)
In-Reply-To: <aee06c9e0701051652m4430f548oe2d91262db9a4a9b@mail.gmail.com>


Le 6 janv. 07 à 01:52, Nathaniel Gray a écrit :

> As Xavier points out, one can use modules to hide basic types, but
> this is pretty clumsy in practice.  There's rumored to be a solution
> using phantom types, but my attempts don't work:
>
> # type 'a boink = int;;
> type 'a boink = int
> # let f = (20 : string boink);;
> val f : string boink = 20
> # let g = (30 : int boink);;
> val g : int boink = 30
> # f;;
> - : string boink = 20
> # g;;
> - : int boink = 30
> # f + g;;
> - : int = 50

Hmmm... the expression
> f + g;;
becomes an int because ( + ) : int -> int -> int

If you write :

((+) : int -> int boink -> string boink) f g

instead, it may do what you meant to do...

Cheers,

Philippe Wang
    mail(at)philippewang.info

  reply	other threads:[~2007-01-06  1:01 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20061203110003.6804FBC6A@yquem.inria.fr>
2006-12-28 11:42 ` Ian Oversby
2006-12-28 16:26   ` [Caml-list] " Jon Harrop
2006-12-28 17:13     ` skaller
2006-12-29  6:05       ` Jacques Garrigue
2006-12-29 11:15         ` Mattias Engdegård
2007-01-06  0:52           ` Nathaniel Gray
2007-01-06  1:01             ` Philippe Wang [this message]
2007-01-06  1:15             ` brogoff
2007-01-06  2:27               ` Martin Jambon
2007-01-08 22:23                 ` Nathaniel Gray
2006-12-28 19:24   ` Manfred Lotz
2006-12-29  1:23   ` [Caml-list] " Andrej Bauer
2006-12-29  9:58     ` Ian Oversby
2006-12-29  2:07   ` Jon Harrop
2007-01-03 16:43     ` Serge Aleynikov
     [not found] <15946.213.30.139.86.1167315231.squirrel@webmail.nerim.net>
2006-12-28 16:03 ` Ian Oversby
2006-12-28 17:00   ` Richard Jones
2006-12-28 22:23   ` Jon Harrop
2006-12-29  9:42     ` Ian Oversby

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=5E08B56F-D4AF-4904-ABD5-789390598F0C@philippewang.info \
    --to=lists@philippewang.info \
    --cc=caml-list@inria.fr \
    --cc=n8gray@gmail.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;
as well as URLs for NNTP newsgroup(s).