summaryrefslogtreecommitdiff
path: root/Haskell-book/17/Identity.hs
blob: 6b5f9a9ee1801fc0746a0c21f90ee7cf1560bafa (plain)
1
2
3
4
5
6
7
8
9
newtype Identity a = Identity a
    deriving (Eq, Show, Ord)

instance Functor Identity where
    fmap f (Identity x) = Identity $ f x

instance Applicative Identity where
    pure x = Identity x
    (Identity f) <*> (Identity y) = Identity $ f y