<div dir="ltr">It would thrash the entire community back more than half-way to where things stood before the Foldable/Traversable proposal and force us back into a world of qualified imports. Everyone who has adapted their code to the status quo over the last 2-3 years and have enjoyed the benefit of a base that doesn't have any internal conflicts would have to go through all the work of reverting their code, or add yet more CPP to hack around the mess. <div><br></div><div>That strikes me, on balance, as a bad option.</div><div><br></div><div><div><div>-Edward</div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Mar 4, 2017 at 9:16 PM,  <span dir="ltr"><<a href="mailto:amindfv@gmail.com" target="_blank">amindfv@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="auto"><div></div><div><span style="background-color:rgba(255,255,255,0)">To Richard's point, though, the ability right now to have e.g. Cofree (Compose [] (Either b)) is in direct conflict with not allowing much simpler terms that no one would ever want to call, e.g.:</span></div><div><span style="background-color:rgba(255,255,255,0)"><br></span></div><div><span style="background-color:rgba(255,255,255,0)">sum ([1,2,3], 1) == 1</span></div><div><span style="background-color:rgba(255,255,255,0)"><br></span></div><div><span style="background-color:rgba(255,255,255,0)">At the moment, we're picking points on the expressiveness-correctness spectrum.</span></div><div><span style="background-color:rgba(255,255,255,0)"><br></span></div><div>Would David's proposal of making Foldable a qualified import not allow us to have our cake and eat it too?</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>Tom</div></font></span><div><div class="h5"><div><br></div><div><br>El 3 mar 2017, a las 23:10, Edward Kmett <<a href="mailto:ekmett@gmail.com" target="_blank">ekmett@gmail.com</a>> escribió:<br><br></div><blockquote type="cite"><div><div dir="ltr">100% this. Cofree Maybe is a a nicely general encoding of a non-empty list that shows how closely related it is to a rose tree Cofree []. It'd lose its ability to be folded if Maybe ceased to be Foldable. <div><br></div><div>When I'm showing how the cofree comonad works, I often take time to work up those examples along with Cofree ((->) e) as an (infinite) Moore machine. About 3-4 examples in, it usually clicks.<div><br></div><div>instances on Either e, and Maybe, Identity, (,) e, etc. are all building blocks that are commonly used for larger things like this.</div><div><br>As you enumerate all the simple functors we have lying around in Haskell, looking at what they do when you compute `Cofree f` or `Free f` tends to be quite informative.<br></div><div><br></div><div>This teaching approach breaks down completely once you start cutting arbitrary holes in instance coverage and making everyone remember where those holes are.</div><div><br></div><div>-Edward</div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Mar 3, 2017 at 5:04 PM, David Menendez <span dir="ltr"><<a href="mailto:dave@zednenem.com" target="_blank">dave@zednenem.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>On Thu, Mar 2, 2017 at 1:12 PM, Kris Nuttycombe <span dir="ltr"><<a href="mailto:kris.nuttycombe@gmail.com" target="_blank">kris.nuttycombe@gmail.com</a>></span> wrote:<br></span><div class="gmail_extra"><div class="gmail_quote"><span><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style: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></blockquote><div><br></div></span><div>Not just polymorphic functions. Many higher-order type constructors have Foldable instances based on their parameters. For example,</div><div><br></div><div><div>data Cofree f a = a :< f (Cofree f a)</div><div><br></div><div>instance Foldable f => Foldable (Cofree f a) where</div><div><span class="m_-6305543542768628158m_7250016047465531849m_-8420925741519727205gmail-Apple-tab-span" style="white-space:pre-wrap">      </span>foldMap f (a :< as) = f a <> foldMap (foldMap f) as</div></div><div><br></div><div>Without the instance for Either b, we lose the instances for Cofree (Either b) and Cofree (Compose [] (Either b)), both of which seem reasonable and useful.</div><span><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div>In particular, the idea that one should make all such functions partial by throwing an error is repugnant.<br></div></div></blockquote><div><br></div></span><div>Yes, that seems like the worst possible solution. Better would be some way to give a warning when calling an overloaded function at a particular type.</div></div><span class="m_-6305543542768628158HOEnZb"><font color="#888888"><div><br></div>-- <br><div class="m_-6305543542768628158m_7250016047465531849m_-8420925741519727205gmail_signature">Dave Menendez <<a href="mailto:dave@zednenem.com" target="_blank">dave@zednenem.com</a>><br><<a href="http://www.eyrie.org/~zednenem/" target="_blank">http://www.eyrie.org/~zednene<wbr>m/</a>></div>
</font></span></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>
</div></blockquote><blockquote type="cite"><div><span>______________________________<wbr>_________________</span><br><span>Libraries mailing list</span><br><span><a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a></span><br><span><a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/libraries</a></span><br></div></blockquote></div></div></div></blockquote></div><br></div>