I am trying to accomplish a mutual binding between two classes in OCaml (a la Mediator Pattern's) and am getting an error upon compilation.
class virtual ['mediator] colleague mIn = object
val m = mIn
method virtual getmediator : 'mediator
end;;
class concreteColleague mIn = object inherit colleague
method getmediator = m
end;;
(* Some other classes here *)
class mediator = object (self)
val mutable myColleague = (None:colleague option)
initializer
myColleague <- Some (new concreteColleague self)
end;;
Error: The class constructor colleague expects 1 type argument(s), but is here applied to 0 type arguments.
I can't say that I'm all that familiar with the ['foo] syntax in the class definition but have resorted to it (with no avail) in trying to allow the mediator to keep a reference to all colleagues and each colleague to its respective mediator while also trying to overcome the importance of a class's definition in source code. How do I go about allowing the colleagues to keep a reference to their mediator?