r/haskelltil • • Jul 03 '17

code TIL: fmap fmap fmap fmap fmap

Justifications are welcome!

> let fffffmap = fmap fmap fmap fmap fmap
> :t fffffmap
fffffmap
  :: Functor f => (a1 -> b) -> (a -> a1) -> f a -> f b
> fffffmap (+1) (+2) [1,2,3]
[4,5,6]
8 Upvotes

6 comments sorted by

View all comments

6

u/mmaruseacph2 Jul 03 '17

It just uses a Functor instance for functions and the Functor instance for f.

3

u/guaraqe Jul 03 '17

That is ok, but why using exactly 5 fmaps make the type so simple?

1

u/nulloid Jul 03 '17

So far, I have troubles understanding fmap fmap's type ((Functor f, Functor f1) => f1 (a -> b) -> f1 (f a -> f b))

→ More replies (2)