<div dir="ltr">+1 from me. We probably also want foldMapAlt:<div><br></div><div> foldMapAlt :: (Foldable t, Alternative f) => (a -> f b) -> t a -> f b</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 28, 2017 at 11:12 PM, Fumiaki Kinoshita <span dir="ltr"><<a href="mailto:fumiexcel@gmail.com" target="_blank">fumiexcel@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"><div>We found this quite useful, but we are not 100% about the name and documentation.</div><div><br></div><div>-- | Try—in the 'Alternative' sense—to return all the values in a 'Foldable'</div><div>-- container.</div><div>--</div><div>-- @</div><div>-- foldAlt ≡ 'listToMaybe' :: [a] -> 'Maybe' a</div><div>-- foldAlt ≡ 'maybeToList' :: 'Maybe' a -> [a]</div><div>-- foldAlt ≡ 'MaybeT' . 'return' :: ('Monad' m) => 'Maybe' a -> 'MaybeT' m a</div><div>-- foldAlt ≡ 'Pipes.ListT' . 'Pipes.each' :: ('Monad' m) => [a] -> 'Pipes.ListT' m a</div><div>-- foldAlt ≡ id :: 'Maybe' a -> 'Maybe' a</div><div>-- @</div><div>foldAlt :: (Foldable t, Alternative f) => t a -> f a</div><div>foldAlt = getAlt . foldMap (Alt . pure)</div><div>{-# INLINE foldAlt #-}</div><div><br></div><div>I propose adding this to either `Data.Foldable` or `Control.Applicative`. Any thoughts?</div></div>
<br>______________________________<wbr>_________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org">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-<wbr>bin/mailman/listinfo/libraries</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">-Andrew Thaddeus Martin</div>
</div>