Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] subtyping, polymorphism, higher order types.....
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Shaddin Doghmi <shaddin@m...>
Subject: [Caml-list] subtyping, polymorphism, higher order types.....
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

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 Archives:
Bug reports: FAQ:
Beginner's list: