Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Polymorphic Variants and Number Parameterized Types
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Brian Rogoff <bpr@b...>
Subject: Re: [Caml-list] Polymorphic Variants and Number Parameterized Types
On Sat, 27 Apr 2002, John Max Skaller wrote:
> Nadji.Gauthier@lip6.fr wrote:
>
> >*disclaimer*
> >This is a long mail, that probably only polymorphic
> >variant adepts and static typing fanatics (like me) will like.
> >Moreover I strongly doubt that it could be very useful.
> >*end of disclaimer*

Nice tricks Nadji! I didn't have time to try out everything you showed,
but I think that trick is more powerful than the other one, which doesn't
use variants. Also, I'm willing to bet that you uncovered a bug in the
type checker (with the "variables can't be generalized" only when in
the compiler). Have you filed a bug report yet?

> There is one importance of such demonstrations: they act as a proof
> that adding integer constants to the static type systems is
> 'safe and sound'.

I think if you're going to take the conclusion that all of these tricks
are worthwhile, you'll want a language with dependent types. In the
general case, you may get undecidable typing (like Cayenne, which is
very very cool) but there are also restricted systems like Xi's DeCaml
which may be useful.

>  Of course, C++ is ahead here, it already admits generics parameterised
> by both types and integers ..  <Ducks for cover ... >

It could be useful when modeling electronic components to have the
bitwidth of a component as part of a type, and to be able to say stuff
in the type system about how that width changes as we build components.
There was a neat posting in c.l.f. recently about such a trick using
(non-"standard" features of) Haskell.

I don't think C++ or Ada generics (which also parameterize over values)
help you much there. Besides, ML uses the module system to parameterize
over values.

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