Created
May 11, 2019 18:50
-
-
Save Pitometsu/b180d522723d2c3ea35dbac8a6880810 to your computer and use it in GitHub Desktop.
OCaml OOP problem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class virtual semigroup = object(self : 'self) | |
method virtual private size : int | |
method plus : 'other. (#semigroup as 'other) -> int = fun other -> self#size + other#size | |
end;; | |
Error: The universal type variable 'other cannot be generalized: | |
it escapes its scope. |
Sad, but simpler expression didn't work:
class virtual a = object(self : 'self)
method virtual private size : int
method plus : 'other. (< 'self; .. > as 'other) -> int = fun other -> self#size + other#size
end;;
Error: The type 'self is not an object type
UPD: not type, but type variable, that's why ^^^
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
But there's still usage problem: