From: Jun Furuse <Jun.Furuse@inria.fr>
To: caml-announce@inria.fr
Subject: [Caml-announce] G'Caml, Caml with Extensional polymorphism extension
Date: Tue, 19 Jun 2001 18:24:24 +0200 [thread overview]
Message-ID: <20010619182424P.Jun.Furuse@inria.fr> (raw)
Hello,
I'm pleased to announce G'Caml, the experimental extension of
the extensional polymorphism([1],[2]) to O'Caml, available at
http://pauillac.inria.fr/~furuse/generics/
You can define non parametric, ad-hoc polymorphic values
(so called "overloaded" or "generic" functions)
using newly added "generic" bindings. For example:
# generic plus = case
| int -> int -> int => (+)
| float -> float -> float => (+.)
;;
This defines an ad-hoc polymorphic function plus, which can work
both for integer and float additions.
# plus 1 2;;
- : int = 3
# plus 1.2 3.4;;
- : int = 4.6
Not only such overloaded arithmetic functions, we can define
many interesting ad-hoc polymorphic values which cannot be imagined
in the normal ML.
G'Caml also provides dynamic values and a toplevel magic printing function,
using the internal framework of extensional polymorphism implementation.
We can encapsulate a value and its type into an object typed dyn.
Then using this encapsulated type information, we can perform
run time type checking:
# dyn 1;;
- : dyn = (1 : int)
# coerce (dyn 1) with
| (x : int) => Printf.printf "It is an int %d.\n" x
| (x : float) => Printf.printf "It is a float %f.\n" x
It is an int 1.
- : unit = ()
The toplevel magic printing is the function which many people have
asked for in this list. It can print out any ML value (well, functions
are just printed as <fun>), including the constructor names of
user defined types (this is available only in the toplevel):
# type foo = Foo of int;;
# Toploop.print (Foo 42);;
Foo 42- : unit = ()
G'Caml is still quite experimental and under development.
I am sure that there are tons of bugs.
Do not expect something almost complete,
like the initial O'Labl release...
I hope you could enjoy it.
--
JPF
[1]
"Extensional Polymorphism".
Catherine Dubois, Francois Rouaix, Pierre Weis.
Proceedings POPL 95.
ftp://ftp.inria.fr/INRIA/Projects/cristal/Francois.Rouaix/generics.dvi.Z
[2]
"Generic polymorphism in ML".
Jun Furuse.
Journees Francophones des Langages Applicatifs 2001
http://pauillac.inria.fr/~furuse/publications/jfla2001.ps.gz
next reply other threads:[~2001-06-19 17:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <4.3.2.7.2.20010720233759.027da4b0@shell16.ba.best.com>
2001-06-19 16:24 ` Jun Furuse [this message]
2001-06-19 17:38 ` [Caml-list] " Jun Furuse
2001-06-19 17:57 ` Brian Rogoff
[not found] ` <20010724160232T.Jun.Furuse@inria.fr>
2001-07-24 18:22 ` Chris Hecker
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=20010619182424P.Jun.Furuse@inria.fr \
--to=jun.furuse@inria.fr \
--cc=caml-announce@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