<div dir="ltr">So basically I can see that the type definitions would seem to deliver the same thing. I test it<div><br></div><div>> (concat . (map (map (*5)))) [[1],[2],[3]]<br></div><div>[5,10,15]<br></div><div>> (map (*5) . concat) [[1],[2],[3]]<br></div><div>[5,10,15]<br></div><div><br></div><div>and can also conclude they give the same answer. So is this an example of referential transparency, i.e., the ability to substitute code and be assured both forms/expressions deliver the same answer?</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Apr 7, 2021 at 12:07 PM Akhra Gannon <<a href="mailto:tanuki@gmail.com">tanuki@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="auto"><div>Check the types!<div dir="auto"><br><div dir="auto"><font face="monospace">map :: (a -> b) -> [a] -> [b]</font></div><div dir="auto"><br></div><div dir="auto">Therefore:</div><div dir="auto"><br></div><div dir="auto"><font face="monospace">map f :: [a] -> [b]</font></div><div dir="auto"><br></div><div dir="auto"><font face="monospace">map . map :: (a -> b) -> [[a]] -> [[b]]</font></div><div dir="auto"><br></div><div dir="auto"><font face="monospace">map (map f) :: [[a]] -> [[b]]</font></div><div dir="auto"><br></div><div dir="auto">And,</div><div dir="auto"><br></div><div dir="auto"><div dir="auto"><font face="monospace">concat :: [[a]] -> [a]</font></div><div dir="auto"><br></div><div dir="auto">Put it all together and you should see how that rewrite works!</div><div dir="auto"><br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Apr 7, 2021, 9:47 AM Galaxy Being <<a href="mailto:borgauf@gmail.com" target="_blank">borgauf@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">I'm in Bird's <i>Thinking Functionally with Haskell</i> and the topic is natural transformations. He says<div><br></div><div><font face="monospace">filter p . map f = map f . filter (p . f)</font></div><div><br></div><div>and he has a proof, but one step of the proof he goes from</div><div><br></div><div><font face="monospace">filter p . map f = concat . map (map f) . map (test (p . f))</font><br></div><div><br></div><div>to </div><div><br></div><div><font face="monospace">filter p . map f = map f . concat . map (test (p . f))<br></font></div><div><br></div><div>which means </div><div><br></div><div><font face="monospace">concat . map (map f) => map f . concat<br></font></div><div><br></div><div>which means</div><div><br></div><div><font face="monospace">map (map f) = map f</font></div><div><br></div><div>... or I'm getting this step wrong somehow. To begin with, I'm having a hard time comprehending <font face="monospace">map(map f)</font>, Any ideas on how this is possible?</div><div><br></div><div>LB</div><div><br></div><div><br></div><div><br></div><div><br></div></div>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org" rel="noreferrer" target="_blank">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
</blockquote></div></div></div>
</div>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
</blockquote></div>