module Extension.Data.Bounded (
BoundedMax(..)
, BoundedMin(..)
) where
import Data.Monoid
newtype BoundedMax a = BoundedMax {getBoundedMax :: a}
deriving( Eq, Ord, Show )
instance (Ord a, Bounded a) => Monoid (BoundedMax a) where
mempty = BoundedMax minBound
(BoundedMax x) `mappend` (BoundedMax y) = BoundedMax (max x y)
newtype BoundedMin a = BoundedMin {getBoundedMin :: a}
deriving( Eq, Ord, Show )
instance (Ord a, Bounded a) => Monoid (BoundedMin a) where
mempty = BoundedMin maxBound
(BoundedMin x) `mappend` (BoundedMin y) = BoundedMin (min x y)