Created
July 24, 2012 04:02
-
-
Save awagner83/3167974 to your computer and use it in GitHub Desktop.
Maybe Haskell
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
data Perhaps a = Definitely a | NoWay deriving Show | |
perhapsMap :: (a -> b) -> Perhaps a -> Perhaps b | |
perhapsMap f (Definitely x) = Definitely (f x) | |
perhapsMap f NoWay = NoWay | |
main = do | |
print $ perhapsMap (+2) (Definitely 10) | |
print $ perhapsMap (+2) (NoWay) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment