Safe Haskell | Safe-Inferred |
---|---|

Language | Haskell2010 |

Myers Diff

This is an implementation of the O(ND) diff algorithm as described in "An O(ND) Difference Algorithm and Its Variations (1986)" http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.4.6927.

## Synopsis

- type Diff a = PolyDiff a a
- data PolyDiff a b
- getTextDiff :: Text -> Text -> Vector (Diff Text)
- getStringDiff :: String -> String -> [Diff Char]
- getGroupedStringDiff :: String -> String -> [Diff String]
- getVectorDiff :: Eq a => Vector a -> Vector a -> Vector (Diff a)
- getGroupedVectorDiff :: Eq a => Vector a -> Vector a -> Vector (Diff (Vector a))
- getVectorDiffBy :: forall a b. (a -> b -> Bool) -> Vector a -> Vector b -> Vector (PolyDiff a b)
- getGroupedVectorDiffBy :: forall a b. (a -> b -> Bool) -> Vector a -> Vector b -> Vector (PolyDiff (Vector a) (Vector b))
- data Edit
- getEditScript :: forall a. Eq a => Vector a -> Vector a -> Vector Edit
- getEditScriptBy :: forall a b. (a -> b -> Bool) -> Vector a -> Vector b -> Vector Edit
- computeDiffFromEditScript :: Vector a -> Vector b -> Vector Edit -> Vector (PolyDiff a b)
- computeGroupedDiffFromEditScript :: Vector a -> Vector b -> Vector Edit -> Vector (PolyDiff (Vector a) (Vector b))
- getDiff :: Eq a => [a] -> [a] -> [Diff a]
- getDiffBy :: (a -> b -> Bool) -> [a] -> [b] -> [PolyDiff a b]
- getGroupedDiff :: Eq a => [a] -> [a] -> [Diff [a]]
- getGroupedDiffBy :: (a -> b -> Bool) -> [a] -> [b] -> [PolyDiff [a] [b]]

# Diffing

A value is either from the `First`

list, the `Second`

or from `Both`

.
`Both`

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
custom equality relation to only perform equality on side of a tuple).

getStringDiff :: String -> String -> [Diff Char] Source #

`String`

diff

You probably want to use `getTextDiff`

with packed strings instead, but this
function doesn't have the roundtripping problem that `getTextDiff`

has.

getGroupedStringDiff :: String -> String -> [Diff String] Source #

Grouped `String`

diff

Like `getStringDiff`

but with entire strings instead of individual characters.

getVectorDiff :: Eq a => Vector a -> Vector a -> Vector (Diff a) Source #

Diff two `Vector`

s

Prefer `getGroupedVectorDiff`

for performance reasons.

getGroupedVectorDiff :: Eq a => Vector a -> Vector a -> Vector (Diff (Vector a)) Source #

Diff two `Vector`

s with grouped results

getVectorDiffBy :: forall a b. (a -> b -> Bool) -> Vector a -> Vector b -> Vector (PolyDiff a b) Source #

Diff two `Vector`

s with different types using a custom equality operator

Prefer `getGroupedVectorDiffBy`

for performance reasons.

getGroupedVectorDiffBy :: forall a b. (a -> b -> Bool) -> Vector a -> Vector b -> Vector (PolyDiff (Vector a) (Vector b)) Source #

Diff two `Vector`

s with grouped results using a custom equality operator

## Internals

getEditScriptBy :: forall a b. (a -> b -> Bool) -> Vector a -> Vector b -> Vector Edit Source #

computeDiffFromEditScript :: Vector a -> Vector b -> Vector Edit -> Vector (PolyDiff a b) Source #

Compute a diff using an edit script.

Prefer `computeGroupedDiffFromEditScript`

for performance reasons.

computeGroupedDiffFromEditScript :: Vector a -> Vector b -> Vector Edit -> Vector (PolyDiff (Vector a) (Vector b)) Source #

Compute a diff using an edit script.

Prefer `computeGroupedDiffFromEditScript`

for performance reasons.

## Backwards compatibility with `Diff`

getDiff :: Eq a => [a] -> [a] -> [Diff a] Source #

For backward compatibility with `Diff`

, use more specific functions if you can.

getDiffBy :: (a -> b -> Bool) -> [a] -> [b] -> [PolyDiff a b] Source #

For backward compatibility with `Diff`

, use more specific functions if you can.