scala-with-cats icon indicating copy to clipboard operation
scala-with-cats copied to clipboard

Misleading Figure 3.7 - Function1 Contramap

Open victorcrrd opened this issue 2 years ago • 1 comments

I am having trouble understanding Figure 3.7 on the Contramap Typeclass for Function1. Looking at Figure 3.5, we have the typeclass instance F[B], the "function to be prepended" A => B and the resulting typeclass instance F[A]. So in the case of Figure 3.7 we have that the type produced by contramap is Function1[Pentagon, Star], which means that we are working with the Contramap Functor instance of functions consuming the base type and producing the Star type. And thus, the image on the left should be an instance of the same typeclass, and the right-hand side of the arrow should be a star too. Another way to interpret the Figure is that the black arrows in the drawings are reversed, but I think that is a bit misleading.

victorcrrd avatar Jan 19 '23 12:01 victorcrrd

Thanks for bringing this up. I think Figure 3.7 is in error. I'm going to leave this up so when we (eventually) get around to this part of the book it can be fixed.

noelwelsh avatar Jan 20 '23 13:01 noelwelsh