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 IAA12960; Fri, 4 Jul 2003 08:43:23 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id IAA15342 for ; Fri, 4 Jul 2003 08:43:22 +0200 (MET DST) Received: from bernarde.athys.fr ([213.244.29.82]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h646hLT09550 for ; Fri, 4 Jul 2003 08:43:21 +0200 (MET DST) Received: from athys.fr (gouais.private.athys.fr [192.168.94.116]) by bernarde.athys.fr (8.11.2/8.8.7) with ESMTP id h645lqG25221 for ; Fri, 4 Jul 2003 07:47:52 +0200 Message-ID: <3F05222E.6020506@athys.fr> Date: Fri, 04 Jul 2003 08:43:58 +0200 From: Daniel Weil User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; fr-FR; rv:1.4) Gecko/20030624 X-Accept-Language: fr, en-us, en MIME-Version: 1.0 To: caml-list@inria.fr Subject: Re: [Caml-list] subtyping, polymorphism, higher order types..... References: <3F043EAB.70503@mitre.org> In-Reply-To: <3F043EAB.70503@mitre.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Spam: no; 0.00; weil:99 caml-list:01 subtyping:01 haskell:01 g'caml:01 unions:01 supertype:01 datatypes:01 commenting:01 narrower:01 bug:01 faq:01 beginner's:01 beginners:01 exupery:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk I've spent these last week some time reading stuff on type classes and Hashkell and I was going to raise the same question : Is it possible to implement Type Classes (in the Haskell way) over Ocaml, at least over CamlLight ? Type classes (which are not object classes) solve in a very elegant way the problem of overloading (especially for arythmetic operators). I'm not sure to have understood precisely what G'Caml does but I don't think G'Caml solve this problem. Shaddin Doghmi wrote: > In my experiences with ocaml, one of the major frustrations i constantly > run into is the lack of subtyping. Polymorphic variants partially fix > that problem, by allowing one to define types as immediate unions (i.e. > without constructors) of other types, hence allowing a value to belong > to both the subtype and the supertype, not to mention multiple unrelated > types. > > However, there is still the issue of defining stuff such as "equality > types", "comparables", and such, allowing overloading of functions on > those. 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). Haskell solves that problem through the use > of type classes. > > 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. > > I wonder if there are any plans to implement such a system in ocaml? if > so, what approach would be taken? > > just a few thoughts..... > > > > ------------------- > 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 > > ------------------- > 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 > > ------------------- > 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 > -- ********************************************************************* * Daniel Weil * * ATHYS * * NOVESPACE Bâtiment B - 100 allée St Exupéry - 38330 Montbonnot * * Tel 33 (0)4 56 38 04 12 Fax 33 (0)4 56 38 04 01 * * daniel.weil@athys.fr * ********************************************************************* ------------------- 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