<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>