Diff: Diff algorithm in pure Haskell

[ algorithms, bsd3, library ] [ Propose Tags ] [ Report a vulnerability ]

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.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1, 0.1.1, 0.1.2, 0.1.3, 0.2.0, 0.3.0, 0.3.1, 0.3.2, 0.3.3, 0.3.4, 0.4.0, 0.4.1, 0.5, 1.0, 1.0.1, 1.0.1.1, 1.0.2, 2.0.0, 2.0.1
Change log CHANGELOG.md
Dependencies array, base (>=4.11 && <=6), pretty (>=1.1) [details]
Tested with ghc ==9.14.1, ghc ==9.12.2, ghc ==9.10.3, ghc ==9.8.4, ghc ==9.6.7, ghc ==9.4.8, ghc ==9.2.8, ghc ==9.0.2, ghc ==8.10.7, ghc ==8.8.4, ghc ==8.6.5, ghc ==8.4.4
License BSD-3-Clause
Author Sterling Clover
Maintainer David Fox <dsf@seereason.com>
Uploaded by DavidFox at 2026-09-06T17:03:29Z
Category Algorithms
Home page https://web.archive.org/web/20150326181224/http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.4.6927
Bug tracker https://github.com/seereason/Diff/issues
Source repo head: git clone https://github.com/seereason/Diff
Distributions Arch:1.0, Fedora:1.0.2, LTSHaskell:1.0.2, Stackage:1.0.2
Reverse Dependencies 62 direct, 309 indirect [details]
Downloads 86012 total (57 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2026-09-06 [all 1 reports]

Readme for Diff-2.0.1

[back to package description]

Diff

This is an 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.

Building & testing

Build with

cabal build

Test with

cabal test

Benchmark with

cabal bench

Checking Diff with LiquidHaskell

The Diff source code can we checked with LiquidHaskell.

LiquidHaskell requires ghc version 9.14.1, and an SMT solver. We have tested the checks with the Z3 SMT solver (versions 4.16, and 4.15.1).

cd Diff-liquidhaskell && cabal build

The Diff-liquidhaskell package is a device to avoid the circular dependency between liquidhaskell and the Diff package.

flowchart LR
    Diff --> liquidhaskell --> liquidhaskell-boot --> Diff

Contributions that update the LiquidHaskell checks are appreciated but not required at this point.

Acknowledgments

The LiquidHaskell static checks were designed and implemented with the support of Tweag, a part of Modus Create. Learn more in this blog post.