[added min priority monoids as well ekmett@gmail.com**20090323050416] { hunk ./Data/Monoid/Ord.hs 16 - -- * Min - , Min(Min,getMin) hunk ./Data/Monoid/Ord.hs 18 + -- * Min + , Min(Min,getMin) hunk ./Data/Monoid/Ord.hs 21 - , Priority(Priority,getPriority) + , MaxPriority(MaxPriority,getMaxPriority) + -- * Min w/ added bottom + , MinPriority(MinPriority,getMinPriority) hunk ./Data/Monoid/Ord.hs 28 + +-- | 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 + mappend = max + hunk ./Data/Monoid/Ord.hs 41 - Min a `mappend` Min b = Min (a `min` b) + mappend = min hunk ./Data/Monoid/Ord.hs 43 --- | The monoid @('max','minBound')@ -newtype Max a = Max { getMax :: a } deriving (Eq,Ord,Show,Read,Bounded) +-- | The monoid @('max','Nothing')@ over @'Maybe' a@ where 'Nothing' is the bottom element. +newtype MaxPriority a = MaxPriority { getMaxPriority :: Maybe a } deriving (Eq,Ord,Show,Read) hunk ./Data/Monoid/Ord.hs 46 -instance (Ord a, Bounded a) => Monoid (Max a) where - mempty = Max minBound - Max a `mappend` Max b = Max (a `max` b) +instance Ord a => Monoid (MaxPriority a) where + mempty = MaxPriority Nothing + mappend = max + +-- | A monoid @('min','Nothing')@ over @'Maybe' a@ where 'Nothing' is the top element +newtype MinPriority a = MinPriority { getMinPriority :: Maybe a } deriving (Eq,Show,Read) hunk ./Data/Monoid/Ord.hs 53 --- | The monoid @('max','Nothing')@ over @'Maybe' a@ -newtype Priority a = Priority { getPriority :: Maybe a } deriving (Eq,Ord,Show,Read) +instance Ord a => Ord (MinPriority a) where + MinPriority Nothing `compare` MinPriority Nothing = EQ + MinPriority Nothing `compare` _ = GT + _ `compare` MinPriority Nothing = LT + MinPriority (Just a) `compare` MinPriority (Just b) = a `compare` b hunk ./Data/Monoid/Ord.hs 59 -instance (Ord a) => Monoid (Priority a) where - mempty = Priority Nothing - Priority a `mappend` Priority b = Priority (a `max` b) +instance Ord a => Monoid (MinPriority a) where + mempty = MinPriority Nothing + mappend = min hunk ./dist/doc/html/lexical-monoids/Data-Monoid-Ord.html 69 ->Min +>Max hunk ./dist/doc/html/lexical-monoids/Data-Monoid-Ord.html 74 ->Max +>Min hunk ./dist/doc/html/lexical-monoids/Data-Monoid-Ord.html 82 +>
Min w/ added bottom +
Max a = Max {
getMax :: a
}newtype Max a = Max MaxPriority a = MaxPrioritygetMax :: agetMaxPriority :: Maybe a Priority a = Priority MinPriority a = MinPrioritygetPrioritygetMinPriorityMax +
newtype Max a Source
The monoid (max,minBound) +
Constructors
Max
getMax :: a
show/hide Instances
Bounded a => Bounded (Max a)
Eq a => Eq (Max a)
Ord a => Ord (Max a)
Read a => Read (Max a)
Show a => Show (Max a)
(Ord a, Bounded a) => Monoid (Max a)
Max +>Max w/ added bottom hunk ./dist/doc/html/lexical-monoids/Data-Monoid-Ord.html 563 -> MaxMaxPriorityminBoundNothing +> over Maybe a where Nothing is the bottom element. hunk ./dist/doc/html/lexical-monoids/Data-Monoid-Ord.html 613 ->MaxMaxPrioritygetMax :: agetMaxPriority :: Maybe ashow/hideshow/hide
Bounded a => Bounded (Max a) (Max (MaxPriority (Max (MaxPriority (Max (MaxPriority (Max (MaxPriority( a, Bounded a) => a => (Max (MaxPriorityMax w/ added bottom +>Min w/ added bottom hunk ./dist/doc/html/lexical-monoids/Data-Monoid-Ord.html 730 -> PriorityMinPriorityThe monoid A monoid maxmin +> where Nothing is the top element hunk ./dist/doc/html/lexical-monoids/Data-Monoid-Ord.html 780 ->PriorityMinPrioritygetPrioritygetMinPriorityshow/hideshow/hide
(Priority (MinPriority (Priority (MinPriority (Priority (MinPriority (Priority (MinPriority (Priority (MinPrioritygetMaxPriorityData.Monoid.OrdgetPrioritygetMinPriorityMaxPriority1 (Type/Class)Data.Monoid.Ord2 (Data Constructor)Data.Monoid.OrdMonoidData.Monoid.Ord, Data.Monoid.Reducer, Data.Monoid.Reducer.Char, Data.Monoid.Lexical.SourcePosition, Data.Monoid.Lexical.UTF8.Decoder, Data.Monoid.Reducer.With, Data.Monoid.Generator, Data.Monoid.Lexical.WordsPriorityMinPriorityMonoidData.Monoid.Ord, Data.Monoid.Reducer, Data.Monoid.Reducer.Char, Data.Monoid.Lexical.SourcePosition, Data.Monoid.Lexical.UTF8.Decoder, Data.Monoid.Reducer.With, Data.Monoid.Generator, Data.Monoid.Lexical.Words -- * Min - , Min(Min,getMin) - -- * Max - , Max(Max,getMax) + -- * Max + , Max(Max,getMax) + -- * Min + , Min(Min,getMin) hunk ./dist/doc/html/lexical-monoids/src/Data-Monoid-Ord.html 29 - , Priority(Priority,getPriority) - ) where - -import Data.Monoid (Monoid, mappend, mempty) + , MaxPriority(MaxPriority,getMaxPriority) + -- * Min w/ added bottom + , MinPriority(MinPriority,getMinPriority) + ) where hunk ./dist/doc/html/lexical-monoids/src/Data-Monoid-Ord.html 34 --- | The monoid given by @('min','maxBound')@ -newtype Min a = Min { getMin :: a } deriving (Eq,Ord,Show,Read,Bounded) +import Data.Monoid (Monoid, mappend, mempty) + hunk ./dist/doc/html/lexical-monoids/src/Data-Monoid-Ord.html 37 -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) +-- | 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 + mappend = max hunk ./dist/doc/html/lexical-monoids/src/Data-Monoid-Ord.html 44 -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) +-- | 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 + mappend = min hunk ./dist/doc/html/lexical-monoids/src/Data-Monoid-Ord.html 51 -instance (Ord a) => Monoid (Priority a) where - mempty = Priority Nothing - Priority a `mappend` Priority b = Priority (a `max` b) +-- | The monoid @('max','Nothing')@ over @'Maybe' a@ where 'Nothing' is the bottom element. +newtype MaxPriority a = MaxPriority { getMaxPriority :: Maybe a } deriving (Eq,Ord,Show,Read) + +instance Ord a => Monoid (MaxPriority a) where + mempty = MaxPriority Nothing + mappend = max + +-- | A monoid @('min','Nothing')@ over @'Maybe' a@ where 'Nothing' is the top element +newtype MinPriority a = MinPriority { getMinPriority :: Maybe a } deriving (Eq,Show,Read) + +instance Ord a => Ord (MinPriority a) where + MinPriority Nothing `compare` MinPriority Nothing = EQ + MinPriority Nothing `compare` _ = GT + _ `compare` MinPriority Nothing = LT + MinPriority (Just a) `compare` MinPriority (Just b) = a `compare` b + +instance Ord a => Monoid (MinPriority a) where + mempty = MinPriority Nothing + mappend = min }