<div dir="ltr">Can you give a few examples of where you'd want that? I can't think of a good application off the top of my head.</div><br><div class="gmail_quote"><div dir="ltr">On Thu, Dec 20, 2018 at 8:22 PM Isaac Elliott <<a href="mailto:isaace71295@gmail.com">isaace71295@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 class="gmail_quote"><div dir="ltr"><div dir="ltr"><div dir="ltr">With the introduction of the 'Ap' monoid in base-4.13, it seems like Applicative based definitions for common folds would be appropriate in base.<div><br></div><div>For example:</div><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">allA :: (Applicative f, Foldable t) => (a -> f Bool) -> t a -> f Bool<br>allA f = fmap getAll . getAp . foldMap (Ap . fmap All . f)<br></blockquote><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">all :: Foldable t => (a -> Bool) -> t a -> Bool<br>all f = runIdentity . allA (Identity . f)</blockquote><div><br></div><div>I've personally written the Applicative version in everyday code. Thoughts?</div></div><div><br></div><div>Isaac</div></div></div></div>
</div></div>
_______________________________________________<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-bin/mailman/listinfo/libraries</a><br>
</blockquote></div>