
25 Jan
2007
25 Jan
'07
9:22 a.m.
liftM (+2) (Just 3 Just 5
:t liftM
forall r (m :: * -> *) a1. (Monad m) => (a1 -> r) -> m a1 -> m r
liftM (+2) Nothing
Nothing
(Thanks to allbery_b for contributing to the discussion on #haskell)
On 1/25/07, John Ky
Is there a built-in function that already does this?
foo :: (a -> b) -> Maybe a -> Maybe b foo f m | isNothing m = Nothing | otherwise = Just (f (fromJust m))
*Main> foo (+2) (Just 3) Just 5 *Main> foo (+2) Nothing Nothing
If so what is it?
If not, what should I call it?
Thanks
-John
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe