summaryrefslogtreecommitdiff
path: root/Haskell-book/16/Short.hs
blob: f6ecd66d5c644c721fa291185b228dbc28d8a414 (plain)
1
2
3
4
5
6
7
8
9
10
module Short where

data Sum a b =
    First a
  | Second b
  deriving (Eq, Show)

instance Functor (Sum a) where
    fmap f (Second x) = Second $ f x
    fmap f (First x) = First x