This workaround worked just fine, thanks a lot! ph. 2015-07-09 1:57 GMT+02:00 Jacques Garrigue : > On 2015/07/09 01:24, Philippe Veber wrote: > > > > Dear camlers, > > > > I obtain an unexpected answer from the toplevel when I enter the > following definition: > > > > OCaml version 4.03.0+dev7-2015-02-08 > > > > # class type ['a] c = > > object > > method m : d > > end > > and d = > > object > > inherit [int] c > > end > > ;; > > class type ['a] c = object constraint 'a = int method m : d end > > and d = object method m : d end > > > > What surprises me is the constraint 'a = int in the definition of c. Is > this is a bug or feature? > > > This is a feature (or at least, the intended behavior) > For classes, type constraints are inferred automatically, but in a > monomorphic way. > A standard workaround is to open the recursion by generalizing definitions: > > class type ['a,'d] c0 = object method m : 'd end > class type d = object inherit ['a,d] c0 end > class type ['a] c = ['a,d] c0 > > Jacques Garrigue