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


-- | Diff algorithm in pure Haskell
--   
--   Implementation of the standard diff algorithm in Haskell.
--   
--   Time complexity is O(ND) (input length * number of differences). Space
--   complexity is O(D^2). Includes utilities for pretty printing.
@package Diff
@version 1.0.2


-- | This is an implementation of the diff algorithm as described in <i>An
--   &lt;math&gt; Difference Algorithm and Its Variations (1986)</i>
--   <a>http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.4.6927</a>.
--   For inputs of size &lt;math&gt; with the number of differences
--   &lt;math&gt; it has &lt;math&gt; time and &lt;math&gt; space
--   complexity.
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.
--   
--   <pre>
--   &gt; getDiff ["a","b","c","d","e"] ["a","c","d","f"]
--   [Both "a" "a",First "b",Both "c" "c",Both "d" "d",First "e",Second "f"]
--   &gt; getDiff "abcde" "acdf"
--   [Both 'a' 'a',First 'b',Both 'c' 'c',Both 'd' 'd',First 'e',Second 'f']
--   </pre>
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.
--   
--   <pre>
--   &gt; getGroupedDiff "abcde" "acdf"
--   [Both "a" "a",First "b",Both "cd" "cd",First "e",Second "f"]
--   </pre>
getGroupedDiff :: Eq a => [a] -> [a] -> [Diff [a]]
getGroupedDiffBy :: (a -> b -> Bool) -> [a] -> [b] -> [PolyDiff [a] [b]]
instance Data.Bifunctor.Bifunctor Data.Algorithm.Diff.PolyDiff
instance GHC.Classes.Eq Data.Algorithm.Diff.DI
instance GHC.Classes.Eq Data.Algorithm.Diff.DL
instance (GHC.Classes.Eq a, GHC.Classes.Eq b) => GHC.Classes.Eq (Data.Algorithm.Diff.PolyDiff a b)
instance GHC.Internal.Base.Functor (Data.Algorithm.Diff.PolyDiff a)
instance GHC.Classes.Ord Data.Algorithm.Diff.DL
instance GHC.Internal.Show.Show Data.Algorithm.Diff.DI
instance GHC.Internal.Show.Show Data.Algorithm.Diff.DL
instance (GHC.Internal.Show.Show a, GHC.Internal.Show.Show b) => GHC.Internal.Show.Show (Data.Algorithm.Diff.PolyDiff a b)


-- | Generates a grouped diff with merged runs, and outputs them in the
--   manner of diff -u
module Data.Algorithm.DiffContext
type ContextDiff c = [Hunk c]
type Hunk c = [Diff [c]]

-- | <pre>
--   &gt; let textA = ["a","b","c","d","e","f","g","h","i","j","k"]
--   &gt; let textB = ["a","b","d","e","f","g","h","i","j"]
--   &gt; let diff = getContextDiff (Just 2) textA textB
--   &gt; 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
--   -k
--   </pre>
getContextDiff :: Eq a => Maybe Int -> [a] -> [a] -> ContextDiff (Numbered a)

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

-- | Pretty print without line numbers.
prettyContextDiffOld :: Doc -> Doc -> (c -> Doc) -> ContextDiff c -> Doc
getContextDiffNumbered :: Eq a => Maybe Int -> [Numbered a] -> [Numbered a] -> ContextDiff (Numbered a)
data Numbered a
Numbered :: Int -> a -> Numbered a
numbered :: [a] -> [Numbered a]
unnumber :: Numbered a -> a

-- | If for some reason you need the line numbers stripped from the result
--   of getContextDiff for backwards compatibility.
unNumberContextDiff :: ContextDiff (Numbered a) -> ContextDiff a

-- | A version of <tt>groupBy</tt> that does not assume the argument
--   function is transitive. This is used to partition the <a>Diff</a> list
--   into segments that begin and end with matching (<a>Both</a>) text,
--   with and have non-matching (<a>First</a> and <a>Second</a>) text in
--   the middle.
--   
--   <pre>
--   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]]
--   </pre>
--   
--   In the first result the list is split anywhere there are two adjacent
--   ones, as desired.
groupBy' :: (a -> a -> Bool) -> [a] -> [[a]]
instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.Algorithm.DiffContext.Numbered a)
instance GHC.Classes.Ord a => GHC.Classes.Ord (Data.Algorithm.DiffContext.Numbered a)
instance GHC.Internal.Show.Show a => GHC.Internal.Show.Show (Data.Algorithm.DiffContext.Numbered a)


-- | 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
--   
--   <pre>
--   &gt; putStr (ppDiff (getGroupedDiff ["a","b","c","d","e"] ["a","c","d","f"]))
--   2d1
--   &lt; b
--   5c4
--   &lt; e
--   ---
--   &gt; f
--   </pre>
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.Eq a => GHC.Classes.Eq (Data.Algorithm.DiffOutput.DiffOperation a)
instance GHC.Classes.Eq Data.Algorithm.DiffOutput.LineRange
instance GHC.Classes.Ord a => GHC.Classes.Ord (Data.Algorithm.DiffOutput.DiffOperation a)
instance GHC.Classes.Ord Data.Algorithm.DiffOutput.LineRange
instance GHC.Internal.Read.Read a => GHC.Internal.Read.Read (Data.Algorithm.DiffOutput.DiffOperation a)
instance GHC.Internal.Read.Read Data.Algorithm.DiffOutput.LineRange
instance GHC.Internal.Show.Show a => GHC.Internal.Show.Show (Data.Algorithm.DiffOutput.DiffOperation a)
instance GHC.Internal.Show.Show Data.Algorithm.DiffOutput.LineRange
