caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Shaddin Doghmi <shaddin@mitre.org>
To: caml-list@inria.fr
Subject: [Caml-list] subtyping, polymorphism, higher order types.....
Date: Thu, 03 Jul 2003 10:33:15 -0400	[thread overview]
Message-ID: <3F043EAB.70503@mitre.org> (raw)

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


             reply	other threads:[~2003-07-03 14:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-03 14:33 Shaddin Doghmi [this message]
2003-07-03 16:23 ` brogoff
2003-07-04  6:43 ` Daniel Weil
2003-07-04 20:45 ` Vasile Rotaru
2003-07-05  2:21   ` Jacques Garrigue
2003-07-05  7:46     ` Fernando Alegre
2003-07-05 15:07     ` Vasile Rotaru

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3F043EAB.70503@mitre.org \
    --to=shaddin@mitre.org \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).