Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
From: Remi VANICAT <vanicat@l...>
Subject: Re: [Caml-list] Allowing many types
Ceri Storey <cez@pkl.net> writes:

> 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
> (AFAIK). 

there is a hidden type variable :

type 'a t = 'a constraint 'a = [> `Foo | `Bar ]

work...


-- 
Rémi Vanicat
vanicat@labri.u-bordeaux.fr
http://dept-info.labri.u-bordeaux.fr/~vanicat
-------------------
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