Data.Algorithm.DiffOutput

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] #

Converts Diffs to DiffOperations

ppDiff :: [Diff [String]] -> String #

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 #

pretty print of diff operations

parsePrettyDiffs :: String -> [DiffOperation LineRange] #

Parse pretty printed Diffs as DiffOperations

type LineNo = Int #

Line number alias

data LineRange #

Line Range: start, end and contents

Constructors

LineRange |
Fields lrNumbers :: (LineNo, LineNo) lrContents :: [String]

#### Instances

Instances details

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

data DiffOperation a #

Diff Operation representing changes to apply

Constructors

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

#### Instances

Instances details

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