[Haskell-beginners] maybe in IO
Mike Ledger
eleventynine at gmail.com
Fri Aug 9 08:38:37 CEST 2013
With Data.Foldable, it's quite nice:
check x assoc = lookup x assoc `for_` \f -> putStrLn ("found " ++ f)
On Fri, Aug 2, 2013 at 1:45 AM, Michael Orlitzky <michael at orlitzky.com>wrote:
> On 08/01/2013 11:00 AM, vold wrote:
> > I've defined a function similar to
> >
> > check x assoc = let found = lookup x assoc in
> > when (isJust found) $ putStrLn $ "found " ++
> fromJust found
> >
> > which I've used several times from within the IO monad. Is there a more
> > compact way of doing this?
> >
>
> maybe (return ()) (putStrLn . ("found " ++)) found
>
> is the best I could do.
>
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20130809/c954e3c7/attachment.htm>
More information about the Beginners
mailing list