-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 You're looking for a polymorphic method:
class a = object method f : 'a. ([>] as 'a) -> unit = fun _ -> () end Peng On Friday 06 March 2009 10:57:43 am Samuel Mimram wrote: > Hi, > > When I try to compile the following code: > > class a = > object > method f (x:[>]) = () > end > > I get the following error: > > Error: Some type variables are unbound in this type: > class a : object method f : [> ] -> unit end > The method f has type ([> ] as 'a) -> unit where 'a is unbound > > Is the binding of [>] to 'a really necessary here? In particular it is > not mentioned in the inferred type... > > Of course I can parametrize the class over 'a as > > class ['a] a = > object > method f (x:[>] as 'a) = () > end > > which now has type > > class ['a] a : object constraint 'a = [> ] method f : 'a -> unit end > > But this seems rather cumbersome. Is there a way to handle this without > mentioning 'a? > > Thanks! > > Cheers, > > Samuel. > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.7 (GNU/Linux) iD8DBQFJsUrkfIRcEFL/JewRAqJ3AKC7Dl6+a97yrs1PKPLDEzL5c3vbVACcDdrJ 16BPB2/+ddTB4OHB/4zQ+LA= =ltZH -----END PGP SIGNATURE----- _______________________________________________ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs