OCaml objects cannot have free type variables in their signatures. Since the type of the argument is foonot completely specified, you need to parameterize the myClassfree variables in the type foo.
class ['a] myClass foo =
object
val dMember = foo
method doIt : 'a = dMember#doSomething
end;;
This definition is of type
class ['a] myClass :
(< doSomething : 'a; .. > as 'b) ->
object val dMember : 'b method doIt : 'a end
dataypes, , 'a tree ( 'a - ). , 'a foo#doSomething, foo.
val x : unit myClass = <obj>
Doing something
- : unit = ()