This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plusOne :: Maybe (Int -> Int) | |
plusOne = Just (+ 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plusOne :: Int -> Maybe Int | |
plusOne x = Just (x + 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plusOne :: Int -> Int | |
plusOne x = x + 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plusOne :: Int -> Maybe Int | |
plusOne x = return (x + 1) | |
monadEx :: Maybe Int | |
monadEx = Just 42 >>= plusOne -- Just 43 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plusOne :: Int -> Maybe Int | |
plusOne x = return (x + 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plusOne :: Int -> Maybe Int | |
plusOne x = Just (x + 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fmapEx :: Maybe Int -- A function returning a Maybe Int | |
fmapEx = fmap (+ 1) (Just 42) -- Just 43 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
withMonad :: Int -> String -> Maybe String | |
withMonad age name = do | |
validateAge age | |
s <- return (greet name) | |
return (greet s) -- Just "Hello Hello John" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
withMonad :: Int -> String -> Maybe String | |
withMonad age name = do | |
validateAge age | |
return (greet name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
withMonad :: Int -> String -> Maybe String | |
withMonad age name = validateAge age >>= \_ -> return (greet name) |
NewerOlder