Functors Flashcards
1
Q
give the implementation of the Functor typeclass
A
class Functor f where fmap :: (a -> b) -> f a -> f b
2
Q
what is the purpose of functors?
A
If a type is an instance of Functor, you can use fmap to apply a function to values in it. Another way of describing fmap is saying that it promotes functions to act on functorial values.
3
Q
give the 1st functor law
A
fmap id = id
4
Q
give the 2nd functor law
A
fmap (g . f) = fmap g . fmap f