Use this subtyping relationship to replace B with a value of type A in a contravariant context.
Use this subtyping relationship to replace B with a value of type
A in a contravariant context. This would commonly be the input
to a function, such as F in: type F[-B] = B => String
. In this
case, we could use A As B to turn an F[B] Into F[A].
As substitutability: A better
<:<
This class exists to aid in the capture proof of subtyping relationships, which can be applied in other context to widen other type
A As B
holds wheneverA
could be used in any negative context that expects aB
. (e.g. if you could pass anA
into any function that expects aB
as input.)This code was ported directly from scalaz to cats using this version from scalaz: https://github.com/scalaz/scalaz/blob/a89b6d63/core/src/main/scala/scalaz/As.scala
The original contribution to scalaz came from Jason Zaugg