November 2017
Intermediate to advanced
670 pages
17h 35m
English
We've seen a functor in the previous chapter in the type class hierarchy diagram. A functor has only one type class method, fmap, which has a type of fmap :: (a -> b) -> f a -> f b. It says--give me a function that takes an a and returns a b, a structure with an a inside it, and I'll give you a structure with a b inside it. The function is applied to each element inside the structure. The fmap function transforms values inside the structure.
We could use the following terms interchangeably:
The important thing to remember is that a functor operates on the element inside the thing (structure/container/box) and returns the structure with the transformed value (not the raw value). ...