Scala standard library contains Option
type.
The Option type itself is covariant type, this is obvious from its declaration sealed abstract class Option[+A]
.
The questions are:
Why its constructor Some
is also covariant
final case class Some[+A](x: A) extends Option[A]
?
Is this somehow needed for pattern matching?
Or maybe it's done for better readability?
For me it seems redundant as I don't see any reason to use Some
directly anywhere except in pattern matching but currently I can't see how it can depend on covariance.