[Haskell-beginners] Alternative

Oliver Charles ollie at ocharles.org.uk
Wed Dec 28 12:10:29 UTC 2016


If you want something even simpler:

asum [Nothing, Just True, Nothing, Just False]

>From Data.Foldable :)

On Wed, 28 Dec 2016, 10:56 am Imants Cekusins, <imantc at gmail.com> wrote:

> discovered this handy snippet today (duh :):
>
> >>> foldl (<|>) Nothing [Nothing, Just 1, Nothing, Just 2]
> Just 1
>
> basically, pick first Just from a list of Maybes
>
>
>
> http://hackage.haskell.org/package/base-4.9.0.0/docs/Control-Applicative.html#g:2
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20161228/e8f7f512/attachment.html>


More information about the Beginners mailing list