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

Hayoo seems to me to do a better job at type signature searching. A ton of
libraries seem to define a toMaybe function for this:
http://hackage.haskell.org/packages/archive/utility-ht/latest/doc/html/Data-...
That isn't built in though.
On Fri, Jun 17, 2011 at 8:24 PM, Tacit Sawk
** 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
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
-- Michael Xavier http://www.michaelxavier.net

On Sat, Jun 18, 2011 at 12:37 AM, Michael Xavier
Hayoo seems to me to do a better job at type signature searching.
Hoogle usually does a great job with type signatures. The problem seems to be that by default it searches through just a small number of packages, and AFAIK you can't tell it to search on all Hackage. See these three links: http://haskell.org/hoogle/?hoogle=Bool+-%3E+a+-%3E+Maybe+a http://haskell.org/hoogle/?hoogle=Bool+-%3E+a+-%3E+Maybe+a+++%2Butility-ht http://haskell.org/hoogle/?hoogle=Bool+-%3E+a+-%3E+m+a+++%2Butility-ht Cheers, -- Felipe.
participants (3)
-
Felipe Almeida Lessa
-
Michael Xavier
-
Tacit Sawk