HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Moduletree-diff-0.3.4Haskell2010

Data.TreeDiff.List

A list diff.

  • 1 type
  • 1 value
  • Packagetree-diff-0.3.4
  • Exports2
  • LanguageHaskell2010
  • LicenceGPL-2.0-or-later
  • SourceList.hs
valuediffBy :: Show a => (a -> a -> Bool) -> [a] -> [a] -> [Edit a]
#

List difference.

Example1 expression
diffBy (==) "hello" "world"[Swp 'h' 'w',Swp 'e' 'o',Swp 'l' 'r',Cpy 'l',Swp 'o' 'd']
Example1 expression
diffBy (==) "kitten" "sitting"[Swp 'k' 's',Cpy 'i',Cpy 't',Cpy 't',Swp 'e' 'i',Cpy 'n',Ins 'g']
Property
\xs ys -> length (diffBy (==) xs ys) >= max (length xs) (length (ys :: String))
Property
\xs ys -> length (diffBy (==) xs ys) <= length xs + length (ys :: String)
datadata Edit a
#

List edit operations

The Swp constructor is redundant, but it let us spot a recursion point when performing tree diffs.

Constructors

  • Ins a

    insert

  • Del a

    delete

  • Cpy a

    copy unchanged

  • Swp a a

    swap, i.e. delete + insert

Instances3Eq, Show, NFData
  • Eq a => Eq (Edit a)Defined in tree-diff-0.3.4 · Data.TreeDiff.List
  • Show a => Show (Edit a)Defined in tree-diff-0.3.4 · Data.TreeDiff.List
  • NFData a => NFData (Edit a)Defined in tree-diff-0.3.4 · Data.TreeDiff.List