Created
May 2, 2016 20:59
-
-
Save danyx23/4ad54832b87748ca420dc09c6e17e111 to your computer and use it in GitHub Desktop.
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
data MyMaybe a = | |
MyNothing | |
| MyJust a | |
deriving (Show) | |
instance Functor MyMaybe where | |
fmap _ MyNothing = MyNothing | |
fmap f (MyJust a) = MyJust (f a) | |
maybeAddFive :: MyMaybe Int -> MyMaybe Int | |
maybeAddFive = | |
fmap (+ 5) | |
main :: IO () | |
main = do | |
print $ maybeAddFive $ MyJust 2 | |
print $ maybeAddFive MyNothing |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment