Variance of Ordered, PartiallyOrdered?

EDIT : Looked further and find some explanation in the documentation for Ordered to not be covariant anymore For the case of tryCompare in PartiallyOrdered the signature set more restriction on passed parameter : def tryCompareTo B >: A (that: B)(implicit arg0: (B) ⇒ PartiallyOrderedB): OptionInt Here the implicit arg0 implies that to be seen as a PartiallyOrderedB instance and thus that it has access to all method defined in this trait.

EDIT : Looked further and find some explanation in the documentation for Ordered to not be covariant anymore. For the case of tryCompare in PartiallyOrdered, the signature set more restriction on passed parameter : def tryCompareTo B >: A (that: B)(implicit arg0: (B) ⇒ PartiallyOrderedB): OptionInt Here the implicit arg0 implies that to be seen as a PartiallyOrderedB instance and thus that it has access to all method defined in this trait.

Thanks for the answer. I guess I understand tryCompareTo, after staring for the signature for a little while. Any insights on the variance of OrderedA, though?

– Daniel Jun 11 at 1:42 I won't edit yet the answer because I'm not sure about this point but I think it is because you can't be sure that OrderedA is equals to OrderedB even if B.

According to the documentation, PartiallyOrderedA is covariant in A, while OrderedA is invariant (but used to be covariant) in A. Why was OrderedA ever covariant in A? Isn't this an obvious violation of the substitution principle?

Why can't OrderedA be contravariant in A? This would allow an OrderedTraversibleChar to be typed as an OrderedStringBuilder, for example. I don't see how this could be problematic.

I'm having trouble understanding the signature of tryCompareTo in PartiallyOrdered. It looks like the argument can be an instance of any supertype of A. Couldn't you pass in any object by calling tryCompareToAny(anything)?

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions