HORIZON HASKELLDocslts/ghc-10.0.x8fef28d2026-11-02Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8fef28d · 2026-11-02

Moduledata-hash-0.2.0.1Haskell98

Data.Hash.Rolling

Efficient implementation of a rolling hash, i.e., the computation of a hash through a moving window of a fixed size n over some stream. All operations are O(1) (in particular, they do not depend on the size of the window).

Some laws that this type satisfies:

  • currentHash rh == foldl1 combine (lastHashes rh)
  • length (lastHashes rh) <= windowSize rh
  • length (lastHashes $ addAndRoll rh a) == windowSize rh -- whenever length (lastHashes rh) == windowSize rh
  • last (lastHashes $ addAndRoll rh x) == hash a
  • init (lastHashes $ addAndRoll rh a) isSuffixOf (lastHashes rh)
Contents
  1. The RollingHash type
  2. Construction and manipulation
  3. Querying
Synopsis

The RollingHash type

Construction and manipulation

Querying