Created
September 2, 2015 12:04
-
-
Save shigemk2/b1eec3957b11a23cd3a6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
-- オレオレバインド(>>=)の実装 | |
applyMaybe :: Maybe a -> (a -> Maybe b) -> Maybe b | |
applyMaybe Nothing f = Nothing | |
applyMaybe (Just x) f = f x | |
main = do | |
print $ Just 3 `applyMaybe` \ x -> Just (x+1) | |
print $ Just "smile" `applyMaybe` \ x -> Just (x ++ " :)") | |
print $ Nothing `applyMaybe` \ x -> Just (x+1) | |
print $ Nothing `applyMaybe` \ x -> Just (x ++ " :)") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment