HORIZON HASKELLDocslts/ghc-9.14.x6d5fdfd2026-10-12Search packagesCtrl K
Theme: |

GHC 9.14.1 · lts/ghc-9.14.x · 6d5fdfd · 2026-10-12

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