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 SAA28281; Thu, 3 Jul 2003 18:24:00 +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 SAA28067 for ; Thu, 3 Jul 2003 18:23:58 +0200 (MET DST) Received: from mail.speakeasy.net (mail11.speakeasy.net [216.254.0.211]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h63GNvf08838 for ; Thu, 3 Jul 2003 18:23:57 +0200 (MET DST) Received: (qmail 24920 invoked from network); 3 Jul 2003 16:23:56 -0000 Received: from unknown (HELO grace.speakeasy.org) ([216.254.0.2]) (envelope-sender ) by mail11.speakeasy.net (qmail-ldap-1.03) with DES-CBC3-SHA encrypted SMTP for ; 3 Jul 2003 16:23:56 -0000 Date: Thu, 3 Jul 2003 09:23:56 -0700 (PDT) From: brogoff@speakeasy.net To: Shaddin Doghmi cc: "caml-list@inria.fr" Subject: Re: [Caml-list] subtyping, polymorphism, higher order types..... In-Reply-To: <3F043EAB.70503@mitre.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam: no; 0.00; brogoff:01 caml-list:01 subtyping:01 g'caml:01 furuse:01 generics:01 datatypes:01 commenting:01 inequality:01 hashing:01 narrower:01 haskell:01 higher-order:01 cristal:01 ocaml:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Thu, 3 Jul 2003, Shaddin Doghmi wrote: > In my experiences with ocaml, one of the major frustrations i constantly > run into is the lack of subtyping. I don't find that a frustration, but you may have been doing OO for a long time. I tend to prefer non OO approaches now. > However, there is still the issue of defining stuff such as "equality > types", "comparables", and such, allowing overloading of functions on > those. You'll be interested in G'Caml http://cristal.inria.fr/~furuse/generics/index.html which will be updated after the release of 3.07. > For example, when writing a large system with many datatypes, i > tend to find myself commenting each type definition with stuff like > "(*equality type*)", to indicate to myself whether or not im allowed to > use the default = operator on that type(for example, a set type would > not get that annotation). You're always allowed to use default equality (inequality, comparison, hashing) so you may want to adopt a coding style that by default uses a module specific comparison. > Another problem i run into is the inability to define parametric higher > order polymorphic types (is this the correct terminology?).. for > example. lets say i want to define the following type: > > type 'a identifier = I of 'a *int | S of 'a*int > > but, what if i want to restrict 'a to a narrower class of types (as > opposed to ad hoc types)... i would wish to say something like: > > type 'identifiable identifier = I of 'a*int | S of 'a*int > > where 'identifiable is a type class of some sort. I am not sure if > Haskell solves this problem using type classes(seems like it could), > Someone experienced in Haskell would probably know. The workaround for higher-order type constructors is described here http://caml.inria.fr/archives/200302/msg00021.html and a very simple modification of this idea (think module type Identifiable) gets pretty close to what I think you want. -- Brian ------------------- 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