-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | O(ND) diff algorithm in haskell.
--   
--   Implementation of the standard diff algorithm, and utilities for
--   pretty printing.
@package Diff
@version 0.4.1


-- | This is an implementation of the O(ND) diff algorithm as described in
--   "An O(ND) Difference Algorithm and Its Variations (1986)"
--   <a>http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.4.6927</a>.
--   It is O(mn) in space. The algorithm is the same one used by standared
--   Unix diff.
module Data.Algorithm.Diff

-- | This is <a>PolyDiff</a> specialized so both sides are the same type.
type Diff a = PolyDiff a a

-- | A value is either from the <a>First</a> list, the <a>Second</a> or
--   from <a>Both</a>. <a>Both</a> contains both the left and right values,
--   in case you are using a form of equality that doesn't check all data
--   (for example, if you are using a newtype to only perform equality on
--   side of a tuple).
data PolyDiff a b
First :: a -> PolyDiff a b
Second :: b -> PolyDiff a b
Both :: a -> b -> PolyDiff a b

-- | Takes two lists and returns a list of differences between them. This
--   is <a>getDiffBy</a> with <a>==</a> used as predicate.
getDiff :: Eq a => [a] -> [a] -> [Diff a]

-- | A form of <a>getDiff</a> with no <a>Eq</a> constraint. Instead, an
--   equality predicate is taken as the first argument.
getDiffBy :: (a -> b -> Bool) -> [a] -> [b] -> [PolyDiff a b]

-- | Takes two lists and returns a list of differences between them,
--   grouped into chunks. This is <a>getGroupedDiffBy</a> with <a>==</a>
--   used as predicate.
getGroupedDiff :: Eq a => [a] -> [a] -> [Diff [a]]
getGroupedDiffBy :: (a -> b -> Bool) -> [a] -> [b] -> [PolyDiff [a] [b]]
instance GHC.Classes.Eq Data.Algorithm.Diff.DI
instance GHC.Show.Show Data.Algorithm.Diff.DI
instance (GHC.Classes.Eq a, GHC.Classes.Eq b) => GHC.Classes.Eq (Data.Algorithm.Diff.PolyDiff a b)
instance (GHC.Show.Show a, GHC.Show.Show b) => GHC.Show.Show (Data.Algorithm.Diff.PolyDiff a b)
instance GHC.Classes.Eq Data.Algorithm.Diff.DL
instance GHC.Show.Show Data.Algorithm.Diff.DL
instance GHC.Classes.Ord Data.Algorithm.Diff.DL


-- | Generates a grouped diff with merged runs, and outputs them in the
--   manner of diff -u
module Data.Algorithm.DiffContext

-- | See
--   <a>https://github.com/seereason/Diff/commit/35596ca45fdd6ee2559cf610bef7a86b4617988a</a>.
--   The original <a>getContextDiff</a> omitted trailing context in diff
--   hunks. This new one corrects the issue. Here is the example from the
--   test suite:
--   
--   <pre>
--   prettyContextDiff (text "file1") (text "file2") text (getContextDiffOld 2 (lines textA) (lines textB))
--   </pre>
--   
--   <ul>
--   <li>-- file1 +++ file2 @@ a b</li>
--   <li>c @<tt> d e </tt>@ i j</li>
--   <li>k</li>
--   </ul>
--   
--   <pre>
--   prettyContextDiff (text "file1") (text "file2") text (getContextDiff 2 (lines textA) (lines textB))
--   </pre>
--   
--   <ul>
--   <li>-- file1 +++ file2 @@ a b</li>
--   <li>c d e @@ i j</li>
--   <li>k</li>
--   </ul>
getContextDiff :: Eq a => Int -> [a] -> [a] -> ContextDiff a

-- | Do a grouped diff and then split up the chunks into runs that contain
--   differences surrounded by N lines of unchanged text. If there is less
--   then 2N+1 lines of unchanged text between two changes, the runs are
--   left merged.
getContextDiffOld :: Eq a => Int -> [a] -> [a] -> ContextDiff a

-- | Pretty print a ContextDiff in the manner of diff -u.
prettyContextDiff :: Doc -> Doc -> (c -> Doc) -> ContextDiff c -> Doc


-- | Generates a string output that is similar to diff normal mode
module Data.Algorithm.DiffOutput

-- | Converts Diffs to DiffOperations
diffToLineRanges :: [Diff [String]] -> [DiffOperation LineRange]

-- | pretty print the differences. The output is similar to the output of
--   the diff utility
ppDiff :: [Diff [String]] -> String

-- | pretty print of diff operations
prettyDiffs :: [DiffOperation LineRange] -> Doc

-- | Parse pretty printed Diffs as DiffOperations
parsePrettyDiffs :: String -> [DiffOperation LineRange]

-- | Line number alias
type LineNo = Int

-- | Line Range: start, end and contents
data LineRange
LineRange :: (LineNo, LineNo) -> [String] -> LineRange
[lrNumbers] :: LineRange -> (LineNo, LineNo)
[lrContents] :: LineRange -> [String]

-- | Diff Operation representing changes to apply
data DiffOperation a
Deletion :: a -> LineNo -> DiffOperation a
Addition :: a -> LineNo -> DiffOperation a
Change :: a -> a -> DiffOperation a
instance GHC.Classes.Ord Data.Algorithm.DiffOutput.LineRange
instance GHC.Classes.Eq Data.Algorithm.DiffOutput.LineRange
instance GHC.Read.Read Data.Algorithm.DiffOutput.LineRange
instance GHC.Show.Show Data.Algorithm.DiffOutput.LineRange
instance GHC.Classes.Ord a => GHC.Classes.Ord (Data.Algorithm.DiffOutput.DiffOperation a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.Algorithm.DiffOutput.DiffOperation a)
instance GHC.Read.Read a => GHC.Read.Read (Data.Algorithm.DiffOutput.DiffOperation a)
instance GHC.Show.Show a => GHC.Show.Show (Data.Algorithm.DiffOutput.DiffOperation a)
