blob: b13c33dfe2f0af726f1968cb16c2f749defd15d2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
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)
|