===== 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 === {{5815_89f1_500.png}} === Reference === ----- === Related === [[Haskell]], [[Functor]], [[Functor category]]