14
newtype Dual a = Dual { getDual :: a }
16
instance Monoid a => Monoid (Dual a) where
18
Dual x `mappend` Dual y = Dual (y `mappend` x)
20
newtype Endo a = Endo { appEndo :: a -> a }
22
instance Monoid (Endo a) where
24
Endo f `mappend` Endo g = Endo (f . g)
26
newtype All = All { getAll :: Bool }
27
deriving (Eq, Ord, Read, Show, Bounded)
29
instance Monoid All where
31
All x `mappend` All y = All (x && y)
33
newtype Any = Any { getAny :: Bool }
34
deriving (Eq, Ord, Read, Show, Bounded)
36
instance Monoid Any where
38
Any x `mappend` Any y = Any (x || y)
40
newtype Sum a = Sum { getSum :: a }
41
deriving (Eq, Ord, Read, Show, Bounded)
43
instance Num a => Monoid (Sum a) where
45
Sum x `mappend` Sum y = Sum (x + y)
47
newtype Product a = Product { getProduct :: a }
48
deriving (Eq, Ord, Read, Show, Bounded)
50
instance Num a => Monoid (Product a) where
52
Product x `mappend` Product y = Product (x * y)