aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-01-28 13:55:46 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-01-28 13:56:38 -0400
commit3327618e5b48afb10a8f98afe15c750d8ed4c416 (patch)
tree25e9b72db536d0cc6c8d55a9d90a2eacf178d95e
parentf351b887265f0abce8d52ffcb7b9b2ee7bd8bc81 (diff)
refactor
-rw-r--r--Logs/Difference/Pure.hs3
-rw-r--r--Types/Difference.hs6
2 files changed, 7 insertions, 2 deletions
diff --git a/Logs/Difference/Pure.hs b/Logs/Difference/Pure.hs
index bbd4d348d..25f3844d6 100644
--- a/Logs/Difference/Pure.hs
+++ b/Logs/Difference/Pure.hs
@@ -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
diff --git a/Types/Difference.hs b/Types/Difference.hs
index f92a30736..e4562a0d6 100644
--- a/Types/Difference.hs
+++ b/Types/Difference.hs
@@ -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]