refactor
This commit is contained in:
parent
ba3825441c
commit
037d86e046
2 changed files with 7 additions and 2 deletions
|
@ -18,8 +18,7 @@ import Types.Difference
|
|||
import Logs.UUIDBased
|
||||
|
||||
parseDifferencesLog :: String -> (M.Map UUID Differences)
|
||||
parseDifferencesLog = simpleMap
|
||||
. parseLog (Just . maybe UnknownDifferences Differences . readish)
|
||||
parseDifferencesLog = simpleMap . parseLog (Just . readDifferences)
|
||||
|
||||
-- The sum of all recorded differences, across all UUIDs.
|
||||
allDifferences :: M.Map UUID Differences -> Differences
|
||||
|
|
|
@ -8,12 +8,14 @@
|
|||
module Types.Difference (
|
||||
Difference(..),
|
||||
Differences(..),
|
||||
readDifferences,
|
||||
getDifferences,
|
||||
differenceConfigKey,
|
||||
differenceConfigVal,
|
||||
hasDifference,
|
||||
) where
|
||||
|
||||
import Utility.PartialPrelude
|
||||
import qualified Git
|
||||
import qualified Git.Config
|
||||
|
||||
|
@ -55,9 +57,13 @@ instance Monoid Differences where
|
|||
mappend (Differences l1) (Differences l2) = Differences (canon (l1 ++ l2))
|
||||
mappend _ _ = UnknownDifferences
|
||||
|
||||
-- Canonical form, allowing comparison.
|
||||
canon :: [Difference] -> [Difference]
|
||||
canon = nub . sort
|
||||
|
||||
readDifferences :: String -> Differences
|
||||
readDifferences = maybe UnknownDifferences Differences . readish
|
||||
|
||||
getDifferences :: Git.Repo -> Differences
|
||||
getDifferences r = Differences $ catMaybes $
|
||||
map getmaybe [minBound .. maxBound]
|
||||
|
|
Loading…
Reference in a new issue