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

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jacques Garrigue <garrigue@k...>
Subject: Re: [Caml-list] Polymorphic Variants and Objects
From: Jim Farrand <jim@farrand.net>

> Take a look at the following OCaml class type definition:
> 
> class type foo =
>   object
>     method bar: [ `A | `B ] 
>   end
> 
> I want to be able to relax the type of bar so that it can return any variant 
> tag, rather than being limited to `A or `B.

What about:

class type ['a] foo =
  object
    constraint 'a = [> `A | `B]
    method bar : 'a
  end

Since you want the variant to be polymorphic, you have to bind its
variable somewhere.

---------------------------------------------------------------------------
Jacques Garrigue      Kyoto University     garrigue at kurims.kyoto-u.ac.jp
		<A HREF=http://wwwfun.kurims.kyoto-u.ac.jp/~garrigue/>JG</A>
-------------------
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