reactive-0.9.3: src/Data/Max.hs
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# OPTIONS -Wall #-}
----------------------------------------------------------------------
-- |
-- Module : Data.Max
-- Copyright : (c) Conal Elliott 2008
-- License : BSD3
--
-- Maintainer : conal@conal.net
-- Stability : experimental
--
-- Max monoid
----------------------------------------------------------------------
module Data.Max (Max(..)) where
import Data.Monoid (Monoid(..))
import Test.QuickCheck (Arbitrary)
import Test.QuickCheck.Checkers (EqProp)
-- | Ordered monoid under 'max'.
newtype Max a = Max { getMax :: a }
deriving (Eq, Ord, Bounded, Read, Show, EqProp, Arbitrary)
instance (Ord a, Bounded a) => Monoid (Max a) where
mempty = Max minBound
Max a `mappend` Max b = Max (a `max` b)