Diff-1.0.2: Diff algorithm in pure Haskell

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]
  }
- data DiffOperation a
  - = Deletion a LineNo
  - | Addition a LineNo
  - | Change a a

# Documentation

diffToLineRanges :: [Diff [String]] -> [DiffOperation LineRange] Source #

Converts Diffs to DiffOperations

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

type LineNo = Int Source #

Line number alias

data LineRange Source #

Line Range: start, end and contents

Constructors

LineRange |

Fields

- lrNumbers :: (LineNo, LineNo)
- lrContents :: [String]

#### Instances

Instances details

Read LineRange Source # |
Instance details Defined in Data.Algorithm.DiffOutput Methods readsPrec :: Int -> ReadS LineRange Source # readList :: ReadS [LineRange] Source # readPrec :: ReadPrec LineRange Source # readListPrec :: ReadPrec [LineRange] Source #
Show LineRange Source # |
Instance details Defined in Data.Algorithm.DiffOutput Methods showsPrec :: Int -> LineRange -> ShowS Source # show :: LineRange -> String Source # showList :: [LineRange] -> ShowS Source #
Eq LineRange Source # |
Instance details Defined in Data.Algorithm.DiffOutput Methods (==) :: LineRange -> LineRange -> Bool Source # (/=) :: LineRange -> LineRange -> Bool Source #
Ord LineRange Source # |

Instance details

Defined in Data.Algorithm.DiffOutput

Methods

compare :: LineRange -> LineRange -> Ordering Source #

(<) :: LineRange -> LineRange -> Bool Source #

(<=) :: LineRange -> LineRange -> Bool Source #

(>) :: LineRange -> LineRange -> Bool Source #

(>=) :: LineRange -> LineRange -> Bool Source #

max :: LineRange -> LineRange -> LineRange Source #

min :: LineRange -> LineRange -> LineRange Source #

data DiffOperation a Source #

Diff Operation representing changes to apply

Constructors

Deletion a LineNo |
Addition a LineNo |
Change a a |

#### Instances

Instances details

Read a => Read (DiffOperation a) Source # |
Instance details Defined in Data.Algorithm.DiffOutput Methods readsPrec :: Int -> ReadS (DiffOperation a) Source # readList :: ReadS [DiffOperation a] Source # readPrec :: ReadPrec (DiffOperation a) Source # readListPrec :: ReadPrec [DiffOperation a] Source #
Show a => Show (DiffOperation a) Source # |
Instance details Defined in Data.Algorithm.DiffOutput Methods showsPrec :: Int -> DiffOperation a -> ShowS Source # show :: DiffOperation a -> String Source # showList :: [DiffOperation a] -> ShowS Source #
Eq a => Eq (DiffOperation a) Source # |
Instance details Defined in Data.Algorithm.DiffOutput Methods (==) :: DiffOperation a -> DiffOperation a -> Bool Source # (/=) :: DiffOperation a -> DiffOperation a -> Bool Source #
Ord a => Ord (DiffOperation a) Source # |

Instance details

Defined in Data.Algorithm.DiffOutput

Methods

compare :: DiffOperation a -> DiffOperation a -> Ordering Source #

(<) :: DiffOperation a -> DiffOperation a -> Bool Source #

(<=) :: DiffOperation a -> DiffOperation a -> Bool Source #

(>) :: DiffOperation a -> DiffOperation a -> Bool Source #

(>=) :: DiffOperation a -> DiffOperation a -> Bool Source #

max :: DiffOperation a -> DiffOperation a -> DiffOperation a Source #

min :: DiffOperation a -> DiffOperation a -> DiffOperation a Source #