
21 Aug
2003
21 Aug
'03
9:21 p.m.
tor 2003-08-21 klockan 22.26 skrev Jon Cast:
Yes. Many complicated proposals have been made, but there's a straightforward, general mechanism:
addMaybe :: Num alpha => Maybe alpha -> Maybe alpha -> Maybe alpha addMaybe a b = a >>= \x -> b >>= \y -> return (x + y)
or
addMaybe a b = do x <- a y <- b return (x + y)
or
addMaybe = Monad.liftM2 (+)
I personally use those monadic lifting functions a lot. Monad.sequence combined with list comprehension is another favorite.
So do I. But that style doesn't work as well with functions that are already in the monad. So, I mentioned the more general style. Jon Cast
7991
Age (days ago)
7991
Last active (days ago)
0 comments
1 participants
participants (1)
-
Jon Cast