<div dir="auto">foldMapDefault and fmapDefault *should* actually perform quite well, by the way, unless the specialized definitions come with rewrite rules.</div><div class="gmail_extra"><br><div class="gmail_quote">On Mar 2, 2017 1:50 PM, "Dan Burton" <<a href="mailto:danburton.email@gmail.com">danburton.email@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Of course errors are swallowed. Look at the type signature.<br><br>concat :: Foldable t => t [b] -> [b]<br>-- t = Either a<br>concat :: Either a [b] -> [b]<div><br>The error type "a" does not appear anywhere in the function's output type. In the event of an error, the only thing it could possibly produce as output is an empty list.<br><br></div><div>I don't think this means that Either's foldable instance is harmful and should be removed. It's a perfectly good instance that behaves in the "obvious" Maybe-like way. I do think this is an argument in favor of using a custom Prelude (which uses functions specialized to lists) when teaching new students.<br><br>Any Traversable instance should absolutely be Foldable, with foldMap = foldMapDefault, or an optimized version that produces the same result. Putting `foldMap = error ...` for any Traversable is out of the question, imo.</div></div><div class="gmail_extra"><br clear="all"><div><div class="m_8613656911272233135gmail_signature" data-smartmail="gmail_signature">-- Dan Burton</div></div>
<br><div class="gmail_quote">On Thu, Mar 2, 2017 at 10:12 AM, Kris Nuttycombe <span dir="ltr"><<a href="mailto:kris.nuttycombe@gmail.com" target="_blank">kris.nuttycombe@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">As with all of these discussions, the point of having Either be Foldable is not that you're going to call foldMap on an Either value directly. Instead, it is that you be able to pass whatever sort of foldable thing you choose (which Either certainly is) to a function that only requires foldability of its input. By removing or damaging the Foldable instance for Either, you don't simply prevent people from encountering problems that will be resolved the first time they test their software - you make a whole universe of nicely polymorphic functions unavailable for them to use without additional effort.<div><br></div><div>In particular, the idea that one should make all such functions partial by throwing an error is repugnant.</div><span class="m_8613656911272233135HOEnZb"><font color="#888888"><div><br></div><div>Kris</div></font></span></div><div class="m_8613656911272233135HOEnZb"><div class="m_8613656911272233135h5"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 2, 2017 at 10:35 AM, Francesco Ariis <span dir="ltr"><<a href="mailto:fa-ml@ariis.it" target="_blank">fa-ml@ariis.it</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>On Thu, Mar 02, 2017 at 05:19:26PM +0000, Oliver Charles wrote:<br>
> Personally, I think it would be a shame to lose foldMap on EIther. I<br>
> frequently foldMap over Maybe values (where mempty is suitable in case of<br>
> "failure"), and I can certainly see myself doing the same thing with Either.<br>
<br>
</span>I am not trying to be polemic, just to see where the community<br>
stands: regarding Either/Maybe: do you have use cases for length<br>
(sum) too?<br>
<div class="m_8613656911272233135m_-3063532771563492589HOEnZb"><div class="m_8613656911272233135m_-3063532771563492589h5"><br>
______________________________<wbr>_________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bi<wbr>n/mailman/listinfo/libraries</a><br>
</div></div></blockquote></div><br></div>
</div></div><br>______________________________<wbr>_________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bi<wbr>n/mailman/listinfo/libraries</a><br>
<br></blockquote></div><br></div>
<br>______________________________<wbr>_________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/libraries</a><br>
<br></blockquote></div></div>