ModuleDiff-1.0.2Haskell2010
Data.Algorithm.DiffContext
Generates a grouped diff with merged runs, and outputs them in the manner of diff -u
- 3 types
- 8 values
- PackageDiff-1.0.2
- Exports11
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceDiffContext.hs
getContextDiff :: Eq a=> Maybe IntNumber of context elements, Nothing means infinite
-> [a]-> [a]-> ContextDiff (Numbered a)
> let textA = ["a","b","c","d","e","f","g","h","i","j","k"]
> let textB = ["a","b","d","e","f","g","h","i","j"]
> let diff = getContextDiff (Just 2) textA textB
> prettyContextDiff (text "file1") (text "file2") (text . unnumber) diff
--- file1
+++ file2
@@ -1,5 +1,4 @@
a
b
-c
d
e
@@ -9,3 +8,2 @@
i
j
-kprettyContextDiff Pretty print a ContextDiff in the manner of diff -u.
prettyContextDiffOld :: DocDocument 1 name
-> DocDocument 2 name
-> (c -> Doc)Element pretty printer
-> ContextDiff c-> Doc
Pretty print without line numbers.
If for some reason you need the line numbers stripped from the result of getContextDiff for backwards compatibility.
A version of groupBy that does not assume the argument function
is transitive. This is used to partition the Diff list into
segments that begin and end with matching (Both) text, with and
have non-matching (First and Second) text in the middle.
let notBoth1 a b = not (a == 1 || b == 1) in
groupBy' notBoth1 [1,1,2,3,1,1,4,5,6,1]
[[1],[1,2,3,1],[1,4,5,6,1]]
groupBy notBoth1 [1,1,2,3,1,1,4,5,6,1]
[[1],[1,2,3],[1],[1,4,5,6],[1]]In the first result the list is split anywhere there are two adjacent ones, as desired.