[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 {} |
newtype Max a = Max MaxPriority a = MaxPrioritygetMax :: a | getMaxPriority :: Maybe a Priority a = Priority MinPriority a = MinPrioritygetPrioritygetMinPriorityMax
+
|
|
|
|
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 :: a | getMaxPriority :: Maybe 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
->PriorityMinPrioritygetPrioritygetMinPriority  | Data.Monoid.Ord |
getPriority | getMinPriorityMaxPriority |
1 (Type/Class) | Data.Monoid.Ord |
2 (Data Constructor) | Data.Monoid.Ord |
Monoid | Data.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 |
PriorityMinPriorityMonoid | Data.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,getMin)
-
- , Max(Max,getMax)
+
+ , Max(Max,getMax)
+
+ , 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)
+
+ , MinPriority(MinPriority,getMinPriority)
+ ) where
hunk ./dist/doc/html/lexical-monoids/src/Data-Monoid-Ord.html 34
-
-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)
-
-
-newtype Max a = Max { getMax :: a } deriving (Eq,Ord,Show,Read,Bounded)
+
+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)
-
-
-newtype Priority a = Priority { getPriority :: Maybe a } deriving (Eq,Ord,Show,Read)
+
+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)
+
+newtype MaxPriority a = MaxPriority { getMaxPriority :: Maybe a } deriving (Eq,Ord,Show,Read)
+
+instance Ord a => Monoid (MaxPriority a) where
+ mempty = MaxPriority Nothing
+ mappend = max
+
+
+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
}