<div dir="ltr">"<span style="font-size:12.8000001907349px">Semantically, "Either left right" can be seen as a container of one or zero "right" that contains out-of-band information of type "left" when it's empty. So when you fmap over it, you only touch the content, not the out-of-band information."</span><div><span style="font-size:12.8000001907349px"><br></span></div><div><span style="font-size:12.8000001907349px">Yup. Whatever he said. ;) ...that's bordering on monadic comparison tutorials if you ask me... LOL. A lot of people may not even know what "in band" and "out-of-band" even means. I grew up with X25, RS232, HDLC etc so that's ok by me. You have to be very very careful about how you explain things to people. One of my favourite videos on YouTube is some guy asking Richard Feynman how magnets work...well, he did ask!</span></div><div><span style="font-size:12.8000001907349px"><a href="https://www.youtube.com/watch?v=wMFPe-DwULM">https://www.youtube.com/watch?v=wMFPe-DwULM</a></span><br></div><div><span style="font-size:12.8000001907349px"><br></span></div><div><span style="font-size:12.8000001907349px"><br></span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 15 April 2015 at 20:39, Chaddaï Fouché <span dir="ltr"><<a href="mailto:chaddai.fouche@gmail.com" target="_blank">chaddai.fouche@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_quote">15 квіт. 2015 19:27 "emacstheviking" <<a href="mailto:objitsu@gmail.com" target="_blank">objitsu@gmail.com</a>> пише:<div><div><br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I just love the way Haskell can blow something really simple into something truly mind blowingly obtuse looking at times!<div>It's no wonder Haskell won't be "mainstream" for a while yet, but that's fine, it means the rest of us can charge better rates for now.</div><div dir="ltr">:)<br></div></div><br></blockquote></div></div></div></blockquote></div><br></div></span><div class="gmail_extra">This is simple. More precisely, it couldn't be otherwise.<br><br><div style="margin-left:40px">data Either l r = Left l | Right r<br></div><br></div><div class="gmail_extra">See how this definition has two type parameters ? The problem was obscured in the first question by the fact that "replicate 3" can be applied to any type. But if you take a less polymorphic function like length, it soon become obvious that this is the way fmap should work :<br><br><div style="margin-left:40px">fmap length (Right "stuff") = length "stuff"<br></div><div style="margin-left:40px">fmap length (Left 5) = length 5 ???? What does that even means ?<br></div><br></div><div class="gmail_extra">Since the type contained by Left and Right are different, you can't in general apply the same function to both possibilities. Now the right type is the last one to occur in "Either left right" so it's the one that's abstracted over in the Functor instance, there is no Functor instance for Either, the instance is for "Either left" with the left type fixed, fmap don't touch the left type, so it can't do anything to a "Left x" value.<br><br></div><div class="gmail_extra">Semantically, "Either left right" can be seen as a container of one or zero "right" that contains out-of-band information of type "left" when it's empty. So when you fmap over it, you only touch the content, not the out-of-band information.<span class="HOEnZb"><font color="#888888"><br><br>-- <br></font></span></div><span class="HOEnZb"><font color="#888888"><div class="gmail_extra">Jedaï<br></div></font></span></div>
<br>_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
<br></blockquote></div><br></div>