From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=AWL,INFO_TLD autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 36503BC0B for ; Sat, 6 Jan 2007 02:01:43 +0100 (CET) Received: from 30.mail-out.ovh.net (30.mail-out.ovh.net [213.186.62.213]) by concorde.inria.fr (8.13.6/8.13.6) with SMTP id l0611gFi005387 for ; Sat, 6 Jan 2007 02:01:43 +0100 Received: (qmail 1322 invoked by uid 503); 6 Jan 2007 01:01:57 -0000 Received: (QMFILT: 1.0); 06 Jan 2007 01:01:57 -0000 Received: from b6.ovh.net (HELO mail56.ha.ovh.net) (213.186.33.56) by 30.mail-out.ovh.net with SMTP; 6 Jan 2007 01:01:57 -0000 Received: from b0.ovh.net (HELO queue-out) (213.186.33.50) by b0.ovh.net with SMTP; 6 Jan 2007 01:01:40 -0000 Received: from vil93-4-82-227-140-227.fbx.proxad.net (HELO ?192.168.1.2?) (lists%philippewang.info@82.227.140.227) by ns0.ovh.net with SMTP; 6 Jan 2007 01:01:38 -0000 In-Reply-To: References: <200612281626.38328.jon@ffconsultancy.com> <1167326001.5338.0.camel@rosella.wigram> <20061229.150507.32045202.garrigue@math.nagoya-u.ac.jp> <200612291115.kBTBF9E26561@virtutech.se> Mime-Version: 1.0 (Apple Message framework v752.2) Content-Type: text/plain; charset=ISO-8859-1; format=flowed Message-Id: <5E08B56F-D4AF-4904-ABD5-789390598F0C@philippewang.info> Cc: caml-list@inria.fr Content-Transfer-Encoding: quoted-printable From: Philippe Wang Subject: Re: [Caml-list] Question on writing efficient Ocaml. Date: Sat, 6 Jan 2007 02:01:28 +0100 To: "Nathaniel Gray" X-Mailer: Apple Mail (2.752.2) X-Ovh-Remote: 82.227.140.227 (vil93-4-82-227-140-227.fbx.proxad.net) X-Ovh-Local: 213.186.33.20 (ns0.ovh.net) X-Miltered: at concorde with ID 459EF4F6.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 val:01 val:01 hmmm:01 cheers:01 caml-list:01 int:01 int:01 modules:02 expression:02 string:02 string:02 types:03 types:03 let:03 Le 6 janv. 07 =E0 01:52, Nathaniel Gray a =E9crit : > 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 =3D int;; > type 'a boink =3D int > # let f =3D (20 : string boink);; > val f : string boink =3D 20 > # let g =3D (30 : int boink);; > val g : int boink =3D 30 > # f;; > - : string boink =3D 20 > # g;; > - : int boink =3D 30 > # f + g;; > - : int =3D 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=