diff --git a/Logs/Difference/Pure.hs b/Logs/Difference/Pure.hs index bbd4d348df..25f3844d60 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 f92a307363..e4562a0d68 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]