<div dir="ltr">I used `anyA` today, to run predicates on things contained in IORefs.<br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Dec 21, 2018 at 10:37 AM Isaac Elliott <<a href="mailto:isaace71295@gmail.com">isaace71295@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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></div></div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div><br></div><div>Isaac</div></div></div></div></blockquote></div></div>