Diff 0.3.1 → 0.3.2
raw patch · 3 files changed
+12/−22 lines, 3 filesdep ~basedep ~prettyPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base, pretty
API changes (from Hackage documentation)
Files
- Diff.cabal +1/−12
- src/Data/Algorithm/DiffContext.hs +6/−6
- src/Data/Algorithm/DiffOutput.hs +5/−4
Diff.cabal view
@@ -1,5 +1,5 @@ name: Diff-version: 0.3.1+version: 0.3.2 synopsis: O(ND) diff algorithm in haskell. description: Implementation of the standard diff algorithm, and utilities for pretty printing. category: Algorithms@@ -9,11 +9,8 @@ maintainer: s.clover@gmail.com Tested-With: GHC == 7.8.4 Build-Type: Simple-build-Depends: base Cabal-Version: >= 1.6 -flag small-base- library build-depends: base >= 3 && <= 6, array, pretty hs-source-dirs: src@@ -22,14 +19,6 @@ Data.Algorithm.DiffOutput Data.Algorithm.DiffContext ghc-options: -O2 -Wall -funbox-strict-fields---- test-suite properties--- hs-source-dirs: src, test--- main-is: Test.hs--- type: exitcode-stdio-1.0---- build-depends:--- QuickCheck >= 2.4, test-framework >= 0.4, test-framework-quickcheck2 >= 0.2, process, directory source-repository head type: darcs
src/Data/Algorithm/DiffContext.hs view
@@ -17,7 +17,7 @@ import Data.Algorithm.Diff (Diff(..), getGroupedDiff) import Data.List (groupBy)-import Data.Monoid ((<>))+import Data.Monoid (mappend) import Text.PrettyPrint (Doc, text, empty, hcat) type ContextDiff c = [[Diff [c]]]@@ -69,8 +69,8 @@ -> Doc prettyContextDiff _ _ _ [] = empty prettyContextDiff old new prettyElem hunks =- hcat . map (<> text "\n") $ (text "--- " <> old :- text "+++ " <> new :+ hcat . map (`mappend` text "\n") $ (text "--- " `mappend` old :+ text "+++ " `mappend` new : concatMap prettyRun hunks) where -- Pretty print a run of adjacent changes@@ -78,6 +78,6 @@ text "@@" : concatMap prettyChange hunk -- Pretty print a single change (e.g. one line of a text file)- prettyChange (Both ts _) = map (\ l -> text " " <> prettyElem l) ts- prettyChange (First ts) = map (\ l -> text "-" <> prettyElem l) ts- prettyChange (Second ts) = map (\ l -> text "+" <> prettyElem l) ts+ prettyChange (Both ts _) = map (\ l -> text " " `mappend` prettyElem l) ts+ prettyChange (First ts) = map (\ l -> text "-" `mappend` prettyElem l) ts+ prettyChange (Second ts) = map (\ l -> text "+" `mappend` prettyElem l) ts
src/Data/Algorithm/DiffOutput.hs view
@@ -13,6 +13,7 @@ module Data.Algorithm.DiffOutput where import Data.Algorithm.Diff import Text.PrettyPrint+import Data.Monoid (mappend) -- | pretty print the differences. The output is similar to the output of the diff utility ppDiff :: [Diff [String]] -> String@@ -50,18 +51,18 @@ prettyDiffs (d : rest) = prettyDiff d $$ prettyDiffs rest where prettyDiff (Deletion inLeft lineNoRight) =- prettyRange (lrNumbers inLeft) <> char 'd' <> int lineNoRight $$+ prettyRange (lrNumbers inLeft) `mappend` char 'd' `mappend` int lineNoRight $$ prettyLines '<' (lrContents inLeft) prettyDiff (Addition inRight lineNoLeft) =- int lineNoLeft <> char 'a' <> prettyRange (lrNumbers inRight) $$+ int lineNoLeft `mappend` char 'a' `mappend` prettyRange (lrNumbers inRight) $$ prettyLines '>' (lrContents inRight) prettyDiff (Change inLeft inRight) =- prettyRange (lrNumbers inLeft) <> char 'c' <> prettyRange (lrNumbers inRight) $$+ prettyRange (lrNumbers inLeft) `mappend` char 'c' `mappend` prettyRange (lrNumbers inRight) $$ prettyLines '<' (lrContents inLeft) $$ text "---" $$ prettyLines '>' (lrContents inRight) prettyRange (start, end) =- if start == end then int start else int start <> comma <> int end+ if start == end then int start else int start `mappend` comma `mappend` int end prettyLines start lins = vcat (map (\l -> char start <+> text l) lins)