PerfectHash: A perfect hashing library for mapping bytestrings to values.

[ bsd3, data, data-structures, deprecated, library ] [ Propose Tags ]
Deprecated in favor of perfecthash

A perfect hashing library for mapping bytestrings to values. Insertion is not supported (by design): this is just a binding to the C-based CMPH library ( Only fromList and lookup operations are supported, but in many circumstances this is all that's required. CI at

[Skip to Readme]


Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


  • No Candidates
Versions [RSS] 0.1, 0.1.1, 0.1.2, 0.1.3, 0.1.4, 0.1.5
Dependencies array, base (>=4.5 && <5.2), binary, bytestring, containers, digest, time [details]
License BSD-3-Clause
Author Mark Wotton <>
Maintainer Mark Wotton <>
Category Data, Data Structures
Bug tracker
Source repo head: git clone
Uploaded by MarkWotton at 2016-04-29T14:47:46Z
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 5407 total (14 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2016-04-29 [all 1 reports]

Readme for PerfectHash-0.1.5

[back to package description]
This is a thin haskell wrapper around the CMPH library, obtainable at
I assume you have it installed in /usr/local/lib.

The motivation is mostly speed, and wren thornton's bytestring-trie seems to be the main competition:

% ./dist/build/benchmark_trie/benchmark_trie
* trie lookup:   1.136ns per iteration / 880403.98 per second.

% ./dist/build/benchmark/benchmark          
* perfect lookup:   0.687ns per iteration / 1456455.69 per second.

it also uses less space in the haskell heap, building once and doing the same number of lookups:

	total alloc = 2,525,223,964 bytes  (excludes profiling overheads)

	total alloc = 9,806,202,096 bytes  (excludes profiling overheads)

although this is not an entirely fair comparison given how much PerfectHash stores on the C side.