It'll be useful to more explain this:
fold method of instance s of stack (created as new stack ) has signature:
when something is pushed into so '_a ('b in class definition) looks like weakly polymorphic. But it work normally like polymorphic type - I can do:
and fold '_a is still not resolved:
What trick is there?
If 'b will be declared in class definition and then used in method defintion like this:
class ['a,'b] stack init = object
method fold f (init:'b) = ....
then it creates truly weakly polymorphic type - after first call to fold '_a is resolved to type of init parameter:
val all : int list = [1; 2; 3; 4]
Error: This expression has type int list but an expression was expected of type int