This is an old revision of the document!


Functor . Haskell

Haskell class

-- definition
class Functor f where
    fmap :: (a -> b) -> f a -> f b
 
-- methods
    (<$) :: a -> f b -> f a
    (<$) = fmap . const
fmap id $\ \leftrightsquigarrow\ $ id
fmap f . fmap g $\ \leftrightsquigarrow\ $ fmap (f . g)

Discussion

In Haskell, the first law implies the second.

Notes

Reference


Link to graph
Log In
Improvements of the human condition