English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Re: [Caml-list] Allowing many types
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-02-11 (10:53)
From: Ceri Storey <cez@p...>
Subject: Re: [Caml-list] Allowing many types
On Sun, Feb 10, 2002 at 08:43:20PM -0500, Ryan Tarpine wrote:
> Is there a type that means "any polymorphic variant"?  Trying to set
>  type primitive = [ `PTest ]
> forces only `PTest to be the value of object_data.  How can I allow 
> anything to be stored there?

According to the output of the toplevel, then the type [> `Foo | `Bar ]
should be usable, but alas, it is not allowable in type specifictions,
giving "Unbound type parameter [..]". 

I've also tried just using plain tuples for this, but then lots of types
become ungeneralisable, eg in the trivial example:
# List.map (fun x -> x) [`X; `Y; `Z];;
- : _[> `X | `Y | `Z] list = [`X; `Y; `Z]

So say, declaring such a variable in a complied module is impossible

Ceri Storey <cez@pkl.net> http://pkl.net/~cez/
vi(1)! postfix(7)! pie(5)!
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr