You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
“Equivalently we could say that B is a subtype of A if there exists a function A => B.”
I don't buy that one and it makes me confused. Say B is a car and A is a vehicle, B is subtype of A but I don't know of functions from vehicles to cars, in particular from a AB-320 or BA-747 to a car. Also the existence of a function between A and B is not relevant to A and B being subtypes of each other but that function is only relevant in the context of relationship of types F[A] and F[B].
What follows in the same section 3.6 reads fine to me but not that specific sentence.
See also Cats' contravariant.md for a discussion (which also is unclear with A <: B meaning A subtype of B or A having fewer instances than B and yet the code above it has B extending A): Subtyping relationships are "lifted backwards" by contravariant functors, such that if F is a lawful contravariant functor and A <: B then F[B] <: F[A], which is expressed by Contravariant.narrow.
Sam Halliday explains better contravariant, covariant, and invariant in FP for mortals, showing that covariant and contravariant extend invariant (see https://leanpub.com/fpmortals/read#leanpub-auto-variance and the nice picture with trait hierarchy where a lower node extends a node depicted higher); he also explains that a 'covariant functor' is just a regular functor as per common usage.
This chapter does make clear that we could use the term "Functor" for 3 type classes, but much much too late (explain this much sooner to avoid confusing the reader): contravariant, covariant, and invariant with covariant being the classical common usage people know (applicative and monad) and that effectively "functor" is sometimes taken to mean "covariant" but at other times the collection of the 3 type classes.
The text was updated successfully, but these errors were encountered:
“Equivalently we could say that
B
is a subtype ofA
if there exists a functionA => B
.”I don't buy that one and it makes me confused. Say
B
is a car andA
is a vehicle,B
is subtype ofA
but I don't know of functions from vehicles to cars, in particular from a AB-320 or BA-747 to a car. Also the existence of a function betweenA
andB
is not relevant toA
andB
being subtypes of each other but that function is only relevant in the context of relationship of typesF[A]
andF[B]
.What follows in the same section 3.6 reads fine to me but not that specific sentence.
See also Cats' contravariant.md for a discussion (which also is unclear with
A <: B
meaning A subtype of B or A having fewer instances than B and yet the code above it has B extending A): Subtyping relationships are "lifted backwards" by contravariant functors, such that if F is a lawful contravariant functor and A <: B then F[B] <: F[A], which is expressed by Contravariant.narrow.Sam Halliday explains better contravariant, covariant, and invariant in FP for mortals, showing that covariant and contravariant extend invariant (see https://leanpub.com/fpmortals/read#leanpub-auto-variance and the nice picture with trait hierarchy where a lower node extends a node depicted higher); he also explains that a 'covariant functor' is just a regular functor as per common usage.
This chapter does make clear that we could use the term "Functor" for 3 type classes, but much much too late (explain this much sooner to avoid confusing the reader): contravariant, covariant, and invariant with covariant being the classical common usage people know (applicative and monad) and that effectively "functor" is sometimes taken to mean "covariant" but at other times the collection of the 3 type classes.
The text was updated successfully, but these errors were encountered: