<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2003/07/c6d81119241d5306bafb0f9bc21d61e9"
  from="Daniel Weil &lt;daniel.weil@a...&gt;"
  author="Daniel Weil"
  date="2003-07-04T06:43:23"
  subject="Re: [Caml-list] subtyping, polymorphism, higher order types....."
  prev="2003/07/1af2bb59803449d5aba637a7223a6f2a"
  next="2003/07/abf5ceeae667fb34e9e077ec470362fb"
  prev-in-thread="2003/07/0235d8bf220e9fe63e99b346ae379d7b"
  next-in-thread="2003/07/9265629f02a5161f666b1798bc5cc5e1"
  prev-thread="2003/07/9d5c44985ef4846fa1879e4f91dc551f"
  next-thread="2003/07/c8147b1a3fde487932256f4013f9c14f"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] subtyping, polymorphism, higher order types.....">
<msg 
  url="2003/07/49ed1832a167d71344f550f25717a45f"
  from="Shaddin Doghmi &lt;shaddin@m...&gt;"
  author="Shaddin Doghmi"
  date="2003-07-03T14:33:27"
  subject="[Caml-list] subtyping, polymorphism, higher order types.....">
<msg 
  url="2003/07/0235d8bf220e9fe63e99b346ae379d7b"
  from="brogoff@s..."
  author="brogoff@s..."
  date="2003-07-03T16:55:32"
  subject="Re: [Caml-list] subtyping, polymorphism, higher order types.....">
</msg>
<msg 
  url="2003/07/c6d81119241d5306bafb0f9bc21d61e9"
  from="Daniel Weil &lt;daniel.weil@a...&gt;"
  author="Daniel Weil"
  date="2003-07-04T06:43:23"
  subject="Re: [Caml-list] subtyping, polymorphism, higher order types.....">
</msg>
<msg 
  url="2003/07/9265629f02a5161f666b1798bc5cc5e1"
  from="Vasile Rotaru &lt;vrotaru@s...&gt;"
  author="Vasile Rotaru"
  date="2003-07-04T21:31:54"
  subject="Re: [Caml-list] subtyping, polymorphism, higher order types.....">
<msg 
  url="2003/07/6fb9d2897cba518cab99e18cea396c7a"
  from="Jacques Garrigue &lt;garrigue@k...&gt;"
  author="Jacques Garrigue"
  date="2003-07-05T02:21:17"
  subject="Re: [Caml-list] subtyping, polymorphism, higher order types.....">
<msg 
  url="2003/07/0c7727744a42d1a2c9eeb08c4df40728"
  from="Fernando Alegre &lt;fernando@c...&gt;"
  author="Fernando Alegre"
  date="2003-07-05T07:46:55"
  subject="Re: [Caml-list] subtyping, polymorphism, higher order types.....">
</msg>
<msg 
  url="2003/07/da08ccf0eadd794f5980a4f8a044d49e"
  from="Vasile Rotaru &lt;vrotaru@s...&gt;"
  author="Vasile Rotaru"
  date="2003-07-05T15:53:36"
  subject="Re: [Caml-list] subtyping, polymorphism, higher order types.....">
</msg>
</msg>
</msg>
</msg>
</thread>

<contents>
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:

&gt; In my experiences with ocaml, one of the major frustrations i constantly
&gt; run into is the lack of subtyping. Polymorphic variants partially fix
&gt; that problem, by allowing one to define types as immediate unions (i.e.
&gt; without constructors) of other types, hence allowing a value to belong
&gt; to both the subtype and the supertype, not to mention multiple unrelated
&gt; types.
&gt;
&gt; However, there is still the issue of defining stuff such as "equality
&gt; types", "comparables", and such, allowing overloading of functions on
&gt; those. For example, when writing a large system with many datatypes, i
&gt; tend to find myself commenting each type definition with stuff like
&gt; "(*equality type*)",  to indicate to myself whether or not im allowed to
&gt; use the default = operator on that type(for example, a set type would
&gt; not get that annotation).  Haskell solves that problem through the use
&gt; of type classes.
&gt;
&gt; Another problem i run into is the inability to define parametric higher
&gt; order polymorphic types (is this the correct terminology?).. for
&gt; example. lets say i want to define the following type:
&gt;
&gt; type 'a identifier = I of 'a *int | S of 'a*int
&gt;
&gt; but, what if i want to restrict 'a to a narrower class of types (as
&gt; opposed to ad hoc types)... i would wish to say something like:
&gt;
&gt; type 'identifiable identifier = I of 'a*int | S of 'a*int
&gt;
&gt; where 'identifiable is a type class of some sort. I am not sure if
&gt; Haskell solves this problem using type classes(seems like it could),
&gt; Someone experienced in Haskell would probably know.
&gt;
&gt; I wonder if there are any plans to implement such a system in ocaml? if
&gt; so, what approach would be taken?
&gt;
&gt; just a few thoughts.....
&gt;
&gt;
&gt;
&gt; -------------------
&gt; To unsubscribe, mail caml-list-request@inria.fr Archives: 
&gt; http://caml.inria.fr
&gt; Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: 
&gt; http://caml.inria.fr/FAQ/
&gt; Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
&gt;
&gt; -------------------
&gt; To unsubscribe, mail caml-list-request@inria.fr Archives: 
&gt; http://caml.inria.fr
&gt; Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: 
&gt; http://caml.inria.fr/FAQ/
&gt; Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
&gt;
&gt; -------------------
&gt; To unsubscribe, mail caml-list-request@inria.fr Archives: 
&gt; http://caml.inria.fr
&gt; Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: 
&gt; http://caml.inria.fr/FAQ/
&gt; Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
&gt;


-- 
*********************************************************************
* 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

</contents>

</message>

