[Haskell-beginners] Is map (map f) just map f?
Akhra Gannon
tanuki at gmail.com
Wed Apr 7 17:06:47 UTC 2021
Check the types!
map :: (a -> b) -> [a] -> [b]
Therefore:
map f :: [a] -> [b]
map . map :: (a -> b) -> [[a]] -> [[b]]
map (map f) :: [[a]] -> [[b]]
And,
concat :: [[a]] -> [a]
Put it all together and you should see how that rewrite works!
On Wed, Apr 7, 2021, 9:47 AM Galaxy Being <borgauf at gmail.com> wrote:
> I'm in Bird's *Thinking Functionally with Haskell* and the topic is
> natural transformations. He says
>
> filter p . map f = map f . filter (p . f)
>
> and he has a proof, but one step of the proof he goes from
>
> filter p . map f = concat . map (map f) . map (test (p . f))
>
> to
>
> filter p . map f = map f . concat . map (test (p . f))
>
> which means
>
> concat . map (map f) => map f . concat
>
> which means
>
> map (map f) = map f
>
> ... or I'm getting this step wrong somehow. To begin with, I'm having a
> hard time comprehending map(map f), Any ideas on how this is possible?
>
> LB
>
>
>
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20210407/e4a483ee/attachment.html>
More information about the Beginners
mailing list