From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id HAA22466; Sat, 23 Oct 2004 07:00:16 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id HAA22367 for ; Sat, 23 Oct 2004 07:00:14 +0200 (MET DST) Received: from smtp3.adl2.internode.on.net (smtp3.adl2.internode.on.net [203.16.214.203]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id i9N50CKJ022226 for ; Sat, 23 Oct 2004 07:00:13 +0200 Received: from [192.168.1.200] (ppp217-99.lns1.syd3.internode.on.net [203.122.217.99]) by smtp3.adl2.internode.on.net (8.12.9/8.12.9) with ESMTP id i9N502OU086641; Sat, 23 Oct 2004 14:30:03 +0930 (CST) Subject: Re: [Caml-list] Single-case union types as strong typedefs From: skaller Reply-To: skaller@users.sourceforge.net To: David Brown Cc: Jacques Garrigue , n8gray@gmail.com, caml-list In-Reply-To: <20041023033915.GA22739@old.davidb.org> References: <20041023.123139.106410806.garrigue@kurims.kyoto-u.ac.jp> <20041023033915.GA22739@old.davidb.org> Content-Type: text/plain Message-Id: <1098507602.7584.163.camel@pelican.wigram> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) Date: 23 Oct 2004 15:00:02 +1000 Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 4179E55C.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 typedefs:01 sourceforge:01 2004:99 2004:99 0900,:01 jacques:01 haskell:01 functors:01 functor:01 simplistic:01 9660:01 glebe:01 bindings:01 ocaml:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Sat, 2004-10-23 at 13:39, David Brown wrote: > On Sat, Oct 23, 2004 at 12:31:39PM +0900, Jacques Garrigue wrote: > > > The problem you describe only occurs when your single constructor has > > only one argument. > > Indeed, this would be nice to have the overhead compiled away. > > I don't remember whether there was a concrete reason not to. > > Another reason is that is breaks compatibility with existing C bindings, or > at least potentially does. That problem would go away with the 'newtype' Jaques mentioned. I'm curious about newtype, since it could do more, and would have to I think, to be worthwhile .. This: newtype metres = float meaning type metres = Metres float means you have to define all the operations on 'metres' all over again: let (++) (Metres x) (Metres y) = Metres (x .+ y) I'd guess in Haskell newtype can benefit from typeclasses? How about using functors in Ocaml somehow .. make 'metres' just an abstract type via a functor Make.length representing the typeclass of lengths? Actually for quantities, you'd use some phantom types so you could represent products of the dimensions, such as square metres too .. so the simplistic constructor representation isn't very good. -- John Skaller, mailto:skaller@users.sf.net voice: 061-2-9660-0850, snail: PO BOX 401 Glebe NSW 2037 Australia Checkout the Felix programming language http://felix.sf.net ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners