<div dir="ltr">I'm sorry to send so many emails, but elem should also be moved into the Foldable class to support optimized versions for searchable containers. We should also move maximum and minimum into the Foldable class to allow optimized versions. We need to settle the semantics of these anyway—Data.List.{maximum,minimum} and Data.Foldable.{maximum,minimum} currently behave differently (left-to-right vs. right-to-left). I think we want "whatever's best", which thankfully leaves the list version with its current semantics.<br><br>David<br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 18, 2014 at 5:49 PM, David Feuer <span dir="ltr"><<a href="mailto:david.feuer@gmail.com" target="_blank">david.feuer@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">R.W. Barton was having trouble spitting out the words "length of a set", and the same holds for all sorts of other things, but unfortunately I think you're right. Proposal amended: put length in the Foldable class.<br></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 18, 2014 at 5:43 PM, Edward Kmett <span dir="ltr"><<a href="mailto:ekmett@gmail.com" target="_blank">ekmett@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">Choosing the name `size` isn't free.<div><br></div><div>If we chose `length` then the existing code continues to work, code that was hiding it on import continues to hide it and you don't get conflicts.</div><div><br></div><div>Picking 'size' is compatible with common practice, but means a ton of modules would break. </div><div><br></div><div>Given the two solutions, one that doesn't break anything and one that does, with negligible differences between them otherwise, I'd prefer the one that causes the least amount of pain.</div><div><br></div><div>-Edward</div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div>On Thu, Sep 18, 2014 at 5:37 PM, David Feuer <span dir="ltr"><<a href="mailto:david.feuer@gmail.com" target="_blank">david.feuer@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div dir="ltr"><div><div><div>To go along with Herbert Valerio Riedel's moving functions from Foldable and Traversable to Prelude, I realized that `null` and `size` make sense for all Foldables; Reid W. Barton noted that these can have optimized implementations for many containers. He also noted that scanl1 and scanr1 make sense for general Traversables. I therefore propose:<br><br></div>Add `null` and `size` to the Foldable class. Default implementations:<br><br></div><div>null = foldr (\_ _ -> False) True<br><br></div><div>size = foldl' (\acc _ -> acc+1) 0<br></div><div><br></div>Add `scanl1` and `scanr1` to the Traversable class. Default implementations are a little less simple.<span><font color="#888888"><br><br>David<br></font></span></div></div>
<br></div></div>_______________________________________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/libraries" target="_blank">http://www.haskell.org/mailman/listinfo/libraries</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div></div>