[Haskell-beginners] Bool -> a -> Maybe a, or something similar
Tacit Sawk
tacit at kwasticat.com
Sat Jun 18 05:24:10 CEST 2011
|Hello!
I tried Hoogle, but it didn't seem to have what I was after. I'm looking
for something like this:
> maybeWhen :: Bool -> a -> Maybe a
> maybeWhen cond =
> if cond
> then Just
> else const Nothing
Is there a builtin that has the above sort of behaviour? I suppose it
can even be generalised:
> maybeWhen :: (MonadPlus m) => Bool -> a -> m a
> maybeWhen cond =
> if cond
> then return
> else const mzero
Tacit
|
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20110618/9840efdf/attachment.htm>
More information about the Beginners
mailing list