scalawithcats / scala-with-cats

Source code for Scala with Cats
http://underscore.io/books/scala-with-cats
390 stars 129 forks source link

Misleading Figure 3.7 - Function1 Contramap #229

Open victorcrrd opened 1 year ago

victorcrrd commented 1 year ago

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.

noelwelsh commented 1 year ago

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.