aboutsummaryrefslogtreecommitdiff
path: root/Types/Difference.hs
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 /Types/Difference.hs
parentf351b887265f0abce8d52ffcb7b9b2ee7bd8bc81 (diff)
refactor
Diffstat (limited to 'Types/Difference.hs')
-rw-r--r--Types/Difference.hs6
1 files changed, 6 insertions, 0 deletions
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]