Skip to content

Instantly share code, notes, and snippets.

@danyx23
Created May 2, 2016 20:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danyx23/4ad54832b87748ca420dc09c6e17e111 to your computer and use it in GitHub Desktop.
Save danyx23/4ad54832b87748ca420dc09c6e17e111 to your computer and use it in GitHub Desktop.
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