caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Objects and variants
@ 2009-03-06 15:57 Samuel Mimram
  2009-03-06 16:10 ` [Caml-list] " Peng Zang
  0 siblings, 1 reply; 2+ messages in thread
From: Samuel Mimram @ 2009-03-06 15:57 UTC (permalink / raw)
  To: caml-list

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.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-03-06 16:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-06 15:57 Objects and variants Samuel Mimram
2009-03-06 16:10 ` [Caml-list] " Peng Zang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).