Version française
Home     About     Download     Resources     Contact us    
Browse thread
Polymorphic variants in class methods
[ 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: Polymorphic variants in class methods
From: malc <malc@pulsesoft.com>

> # class foo = object method moo = `Bar end;;
> Some type variables are unbound in this type:
>   class foo : object method moo : [> `Bar] end
> The method moo has type [> `Bar] where 'a is unbound

You can see it as a bug in the error message printer: the real message
should be

        The method moo has type ([> `Bar] as 'a) where 'a is unbound

That is, the type [> `Bar] is not fully specified (it contains a row
variable), and as a result you cannot use it in a method type, which
must be fully specified.
Easy solution, add a type annotation:
        # class foo = object method moo : [`Bar] = `Bar end;;
        class foo : object method moo : [ `Bar] end

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