Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Objects and variants
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2009-03-06 (15:57)
From: Samuel Mimram <samuel.mimram@e...>
Subject: Objects and variants

When I try to compile the following code:

class a =
  method f (x:[>]) = ()

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 =
  method f (x:[>] as 'a) = ()

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?