
On May 8, 2010, at 01:16 , Ivan Lazar Miljenovic wrote:
David Menendez
writes: On Sat, May 8, 2010 at 12:15 AM, Ivan Lazar Miljenovic
Well, any time you have a do-block like this you're using failable patterns:
maybeAdd :: Maybe Int -> Maybe Int -> Maybe Int maybeAdd mx my = do x <- mx y <- my return $ x + y
This is true in the sense that the translation for the do syntax in the Haskell report uses fail.
Huh? What about "maybeAdd (Just 2) Nothing" ?
Isn't that handled by the definition of (>>=) in Maybe, as opposed to by invoking fail?
instance Monad Maybe where -- ... Nothing >>= _ = Nothing (Just x) >>= f = f x
-- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH