3 ms·
When the type is some sort of container type (Maybe, Either, List, Tuple and so on), the functor interface gives you a function that will change the contents of
by kqr 12y ago
When the type is some sort of container type (Maybe, Either, List, Tuple and so on), the functor interface gives you a function that will change the contents of the container, while preserving the container structure. Example:
fmap (*3) (Just 12) === Just 36
When the type is some sort of computation type (IO, Promise, STM, Parser, unwrapped Reader), the functor interface gives you a function that will take a function and compose it with the computation. In other words, the result of the computation will be passed through your specified function before it is finally returned. Example:
fmap (+5) (getPromise age)
-- promise age is filled with 43 and
-- the fmap call will return 48