use Monoid instance for Ordering
This commit is contained in:
parent
a7dffcbd7a
commit
5a37266080
2 changed files with 3 additions and 14 deletions
|
@ -14,6 +14,7 @@ import Utility.Tense
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
import Data.Text (Text)
|
import Data.Text (Text)
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
|
import Data.Monoid
|
||||||
|
|
||||||
{- This is as many alerts as it makes sense to display at a time.
|
{- This is as many alerts as it makes sense to display at a time.
|
||||||
- A display might be smaller, or larger, the point is to not overwhelm the
|
- A display might be smaller, or larger, the point is to not overwhelm the
|
||||||
|
@ -43,8 +44,8 @@ compareAlertPairs
|
||||||
(aid, Alert { alertClass = aclass, alertPriority = aprio })
|
(aid, Alert { alertClass = aclass, alertPriority = aprio })
|
||||||
(bid, Alert { alertClass = bclass, alertPriority = bprio })
|
(bid, Alert { alertClass = bclass, alertPriority = bprio })
|
||||||
= compare aprio bprio
|
= compare aprio bprio
|
||||||
`thenOrd` compare aid bid
|
`mappend` compare aid bid
|
||||||
`thenOrd` compare aclass bclass
|
`mappend` compare aclass bclass
|
||||||
|
|
||||||
sortAlertPairs :: [AlertPair] -> [AlertPair]
|
sortAlertPairs :: [AlertPair] -> [AlertPair]
|
||||||
sortAlertPairs = sortBy compareAlertPairs
|
sortAlertPairs = sortBy compareAlertPairs
|
||||||
|
|
|
@ -109,18 +109,6 @@ massReplace vs = go [] vs
|
||||||
go (replacement:acc) vs (drop (length val) s)
|
go (replacement:acc) vs (drop (length val) s)
|
||||||
| otherwise = go acc rest s
|
| otherwise = go acc rest s
|
||||||
|
|
||||||
{- Given two orderings, returns the second if the first is EQ and returns
|
|
||||||
- the first otherwise.
|
|
||||||
-
|
|
||||||
- Example use:
|
|
||||||
-
|
|
||||||
- compare lname1 lname2 `thenOrd` compare fname1 fname2
|
|
||||||
-}
|
|
||||||
thenOrd :: Ordering -> Ordering -> Ordering
|
|
||||||
thenOrd EQ x = x
|
|
||||||
thenOrd x _ = x
|
|
||||||
{-# INLINE thenOrd #-}
|
|
||||||
|
|
||||||
{- Wrapper around hGetBufSome that returns a String.
|
{- Wrapper around hGetBufSome that returns a String.
|
||||||
-
|
-
|
||||||
- The null string is returned on eof, otherwise returns whatever
|
- The null string is returned on eof, otherwise returns whatever
|
||||||
|
|
Loading…
Reference in a new issue