import Control.Applicative data MyMaybe a = MyNothing | MyJust a deriving (Show) instance Functor MyMaybe where fmap _ MyNothing = MyNothing fmap f (MyJust x) = MyJust (f x) instance Applicative MyMaybe where pure x = MyJust x MyNothing <*> _ = MyNothing _ <*> MyNothing = MyNothing (MyJust f) <*> (MyJust g) = MyJust (f g)