| Copyright | (c) Sterling Clover 2008-2011 Kevin Charter 2011 |
|---|---|
| License | BSD 3 Clause |
| Maintainer | s.clover@gmail.com |
| Stability | experimental |
| Portability | portable |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Data.Algorithm.DiffOutput
Description
Generates a string output that is similar to diff normal mode.
Synopsis
- diffToLineRanges :: [Diff [String]] -> [DiffOperation LineRange]
- ppDiff :: [Diff [String]] -> String
- prettyDiffs :: [DiffOperation LineRange] -> Doc
- parsePrettyDiffs :: String -> [DiffOperation LineRange]
- type LineNo = Int
- data LineRange = LineRange {
- lrNumbers :: (LineNo, LineNo)
- lrContents :: [String]
- mkLineRange :: Int -> [String] -> LineRange
- data DiffOperation a
Documentation
diffToLineRanges :: [Diff [String]] -> [DiffOperation LineRange] Source #
ppDiff :: [Diff [String]] -> String Source #
Pretty print the differences. The output is similar to the output of the diff utility.
> putStr (ppDiff (getGroupedDiff ["a","b","c","d","e"] ["a","c","d","f"])) 2d1 < b 5c4 < e --- > f
prettyDiffs :: [DiffOperation LineRange] -> Doc Source #
Pretty print of diff operations.
parsePrettyDiffs :: String -> [DiffOperation LineRange] Source #
Parse pretty printed Diffs as DiffOperations.
Line Range: start, end and contents.
The following invariants hold:
snd lrNumbers >= fst lrNumbers snd lrNumbers - fst lrNumbers + 1 == length lrContents
which imply lrContents cannot be empty.
Constructors
| LineRange | |
Fields
| |
mkLineRange :: Int -> [String] -> LineRange Source #
Smart constructor for LineRange that computes the end line from the
start line and the content length, guaranteeing that its content length and
range match.
data DiffOperation a Source #
Diff operation representing changes to apply.
Constructors
| Deletion a LineNo | Element deleted on the left input, line number preceding the deleted lines in the right input. |
| Addition a LineNo | Element added from the right input, line number preceding the added lines in the left input. |
| Change a a | Element changed from the left input to the right input. |