sydtest-0.13.0.4: A modern testing framework for Haskell with good defaults and advanced testing features.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Test.Syd.Diff

Synopsis

Diffing

type Diff a = PolyDiff a a Source #

data PolyDiff a b Source #

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

Constructors

First a 
Second b 
Both a b 

Instances

Instances details
(Show a, Show b) => Show (PolyDiff a b) Source # 
Instance details

Defined in Test.Syd.Diff

Methods

showsPrec :: Int -> PolyDiff a b -> ShowS #

show :: PolyDiff a b -> String #

showList :: [PolyDiff a b] -> ShowS #

(Eq a, Eq b) => Eq (PolyDiff a b) Source # 
Instance details

Defined in Test.Syd.Diff

Methods

(==) :: PolyDiff a b -> PolyDiff a b -> Bool #

(/=) :: PolyDiff a b -> PolyDiff a b -> Bool #

getTextDiff :: Text -> Text -> Vector (Diff Text) Source #

Text diff

Uses pack and unpack, so does not roundtrip. It uses pack and unpack because Text is not the same as Vector Char; You can't index a text in O(1) time, it takes O(n) time.

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 vectors

Prefer getGroupedVectorDiff for performance reasons.

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

Diff two vectors with grouped results

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

Diff two vectors 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 vectors with grouped results using a custom equality operator

Internals

data Edit Source #

Constructors

Delete

Delete from the old vector

Fields

  • Int

    position in the old vector

  • Int

    number of items to delete

Insert

Insert into the old vector

Fields

  • Int

    position in the old vector

  • Int

    position in the new vector

  • Int

    number of items to insert

Instances

Instances details
Show Edit Source # 
Instance details

Defined in Test.Syd.Diff

Methods

showsPrec :: Int -> Edit -> ShowS #

show :: Edit -> String #

showList :: [Edit] -> ShowS #

Eq Edit Source # 
Instance details

Defined in Test.Syd.Diff

Methods

(==) :: Edit -> Edit -> Bool #

(/=) :: Edit -> Edit -> Bool #

Ord Edit Source # 
Instance details

Defined in Test.Syd.Diff

Methods

compare :: Edit -> Edit -> Ordering #

(<) :: Edit -> Edit -> Bool #

(<=) :: Edit -> Edit -> Bool #

(>) :: Edit -> Edit -> Bool #

(>=) :: Edit -> Edit -> Bool #

max :: Edit -> Edit -> Edit #

min :: Edit -> Edit -> Edit #

getEditScript :: forall a. Eq a => Vector a -> Vector a -> Vector Edit Source #

Compute the edit script to turn a given vector into the second given vector

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

Compute the edit script to turn a given vector into the second given vector with a custom equality operator

From https://blog.robertelder.org/diff-algorithm/

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.

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

For backward compatibility with Diff, use more specific functions if you can.

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

For backward compatibility with Diff, use more specific functions if you can.