[improved haddock on Data.Monoid.Ord ekmett@gmail.com**20090323045109] { hunk ./Data/Monoid/Ord.hs 1 +----------------------------------------------------------------------------- +---- | +---- Module : Data.Monoid.Ord +---- Copyright : (c) Edward Kmett 2009 +---- License : BSD-style +---- Maintainer : libraries@haskell.org +---- Stability : provisional +---- Portability : portable +---- +---- Some 'Monoid' instances that should probably be in "Data.Monoid". +---- +------------------------------------------------------------------------------- + hunk ./Data/Monoid/Ord.hs 16 + -- * Min hunk ./Data/Monoid/Ord.hs 18 + -- * Max hunk ./Data/Monoid/Ord.hs 20 + -- * Max w/ added bottom hunk ./Data/Monoid/Ord.hs 25 - + +-- | The monoid given by @('min','maxBound')@ hunk ./Data/Monoid/Ord.hs 33 +-- | The monoid @('max','minBound')@ hunk ./Data/Monoid/Ord.hs 40 +-- | The monoid @('max','Nothing')@ over @'Maybe' a@ hunk ./dist/doc/html/lexical-monoids/Data-Monoid-Ord.html 56 +>
Contents
Min +
Max +
Max w/ added bottom +
DocumentationSynopsis
newtype Min a = Min {
getMin :: a
}
newtype Max a = Max {
getMax :: a
}
newtype Priority a = Priority {
getPriority :: Maybe a
}
Min +The monoid given by (min,maxBound) +Max +The monoid (max,minBound) +Max w/ added bottom +The monoid (max,Nothing) over Maybe a +module Data.Monoid.Ord - ( module Data.Monoid - , Min(Min,getMin) - , Max(Max,getMax) - , Priority(Priority,getPriority) - ) where - -import Data.Monoid (Monoid, mappend, mempty) - -newtype Min a = Min { getMin :: a } deriving (Eq,Ord,Show,Read,Bounded) - -instance (Ord a, Bounded a) => Monoid (Min a) where - mempty = Min maxBound - Min a `mappend` Min b = Min (a `min` b) - -newtype Max a = Max { getMax :: a } deriving (Eq,Ord,Show,Read,Bounded) - -instance (Ord a, Bounded a) => Monoid (Max a) where - mempty = Max minBound - Max a `mappend` Max b = Max (a `max` b) - -newtype Priority a = Priority { getPriority :: Maybe a } deriving (Eq,Ord,Show,Read) +
-----------------------------------------------------------------------------
+---- |
+---- Module      :  Data.Monoid.Ord
+---- Copyright   :  (c) Edward Kmett 2009
+---- License     :  BSD-style
+---- Maintainer  :  libraries@haskell.org
+---- Stability   :  provisional
+---- Portability :  portable
+----
+---- Some 'Monoid' instances that should probably be in "Data.Monoid".
+----
+-------------------------------------------------------------------------------
+
+module Data.Monoid.Ord 
+    ( module Data.Monoid
+    -- * Min
+    , Min(Min,getMin)
+    -- * Max
+    , Max(Max,getMax)
+    -- * Max w/ added bottom
+    , Priority(Priority,getPriority)
+    ) where
hunk ./dist/doc/html/lexical-monoids/src/Data-Monoid-Ord.html 32
-instance (Ord a) => Monoid (Priority a) where
-    mempty = Priority Nothing
-    Priority a `mappend` Priority b = Priority (a `max` b)
+import Data.Monoid (Monoid, mappend, mempty)
+
+-- | The monoid given by @('min','maxBound')@
+newtype Min a = Min { getMin :: a } deriving (Eq,Ord,Show,Read,Bounded)
+
+instance (Ord a, Bounded a) => Monoid (Min a) where
+    mempty = Min maxBound
+    Min a `mappend` Min b = Min (a `min` b)
+
+-- | The monoid @('max','minBound')@
+newtype Max a = Max { getMax :: a } deriving (Eq,Ord,Show,Read,Bounded)
+
+instance (Ord a, Bounded a) => Monoid (Max a) where
+    mempty = Max minBound
+    Max a `mappend` Max b = Max (a `max` b)
+
+-- | The monoid @('max','Nothing')@ over @'Maybe' a@
+newtype Priority a = Priority { getPriority :: Maybe a } deriving (Eq,Ord,Show,Read)
+
+instance (Ord a) => Monoid (Priority a) where
+    mempty = Priority Nothing
+    Priority a `mappend` Priority b = Priority (a `max` b)
}