A class for types that can be converted to a hash value http://github.com/tibbe/hashable

Version on this page:
LTS Haskell 8.12:
Stackage Nightly 2017-04-24:
Latest on Hackage:
Maintained by johan.tibell@gmail.com

Module documentation for

The hashable package

This package defines a class, Hashable, for types that can be converted to a hash value. This class exists for the benefit of hashing-based data structures. The package provides instances for basic types and a way to combine hash values.



  • Add support for type-indexed Typeable.

  • Rework the Generic hashable for sums.


  • Add Hashable1 and Hashable2

  • Add instances for: Eq1, Ord1, Show1, Ptr, FunPtr, IntPtr, WordPtr

  • Add Hashed type for caching the hash function result.


  • Add instances for: Unique, Version, Fixed, NonEmpty, Min, Max, Arg, First, Last, WrappedMonoid, Option

  • Support GHC 8.0


  • Support integer-simple.


  • Add support for GHC 7.10 typeRepFingerprint


  • Added support for random 1.1.*.


  • Silence integer literal overflow warning

  • Add support for GHC 7.10 integer-gmp2 & Natural

  • Add instance for Data.Void

  • Make the SSE .cabal flags manual

  • Add an upper bound on bytestring


  • Add instances for Data.ByteString.Short

  • Use a 32-bit default salt on 32-bit archs.


  • Revert instances to their 1.1 implementations to regain the performance we had then.

  • Remove use of random salt altogether. Without using SipHash the benefit is unclear (i.e. collision attacks still work) and the complexity is no longer worth it.

  • Documentation improvements.


  • Fix for GHC 7.0.


  • Stop using SipHash. The current implementation still has segfault causing bugs that we won't be able to fix soon.

  • Stop using Wang hash. It degrades performance of fixed-size integer hashing too much.


  • Fix linking issue when SSE was disabled.

  • Hash small signed Integers correctly.


  • Add flags to control usage of SSE.


  • Fix another segfault caused by SSE2 code.


  • More portability fixes.

  • Force stack alignment to 16 bytes everywhere. Fixes a segfault.

  • Fix bug where code relied on rewrite rules firing for correctness.


  • Update docs to match code.

  • Work around bug in GHCi runtime linker, which never call static initializers.


  • Make building of SSE 4.1 code conditional, as it doesn't work on all platforms.

  • Use a fixed salt, but allow random salting. Random salting by default broke people's code.


  • Work around ghci linker bug on Windows.


  • Fix performance bug in SSE implementation of SipHash.

  • Fix segfault due to incorrect stack alignment on Windows.


  • Switch string hashing from FNV-1 to SipHash, in an effort to prevent collision attacks.

  • Switch fixed-size integer hashing to Wang hash.

  • The default salt now switched on every program run, in an effort to prevent collision attacks.

  • Move hash method out of Hashable type class.

  • Add support for generic instance deriving.

  • Add instance for Ordering.


  • Bug fix for bytestring < 0.10.0.


  • Switch string hashing from Bernstein to FNV-1

  • Faster instance for Integer.

  • Update dependency on base, ghc-prim

  • Now works with GHC 7.6.


  • Add instance for TypeRep.

  • Update dependency on test-framework.


  • Bug fix for GHC 7.4


  • Update dependency on test-framework.

  • Improve documentation of combine.


  • Add instances for Interger, Ratio, Float, Double, and StableName.

  • Fix hash collision issues for lists and tuples when using a user-specified salt.


  • Improved instances for tuples and lists.

  • Add instances for StableName, Float, Double, Integer, and Ratio.


  • Add hashWithSalt, which allows the user to create different hash values for the same input by providing different seeds. This is useful for application like Cuckoo hashing which need a family of hash functions.

  • Fix a bug in the Hashable instance for Int64/Word64 on 32-bit platforms.

  • Improved resilience to leading zero in the input being hashed.


  • Add instance for: strict and lazy Texts, ThreadId

  • Add hashPtrWithSalt and hashByteArrayWithSalt.

  • Faster ByteArray# hashing.

  • Fix a signedness bug that affected ByteString.

  • Fix ByteString hashing to work correctly on both 32 and 64-bit platforms.


  • Fix bug in Hashable instance for lazy ByteStrings where differences in the internal structure of the ByteString could cause different hash values for ByteStrings that are equal according to ==.


  • Add two helpers for creating Hashable instances: hashPtr and hashByteArray.


  • Separate Hashable class to its own package from hashmap
Used by 474 packages:
Agda, AhoCorasick, BiobaseInfernal, BiobaseTypes, BiobaseXNA, CTRex, CurryDB, DSH, Deadpan-DDP, EtaMOO, HLearn-algebra, HLearn-classification, HMap, HSet, HUnit-Plus, HongoDB, JunkDB-driver-hashtables, LambdaHack, LibClang, LinguisticsTypes, MagicHaskeller, MuCheck, NXTDSL, Neks, OpenAFP, OpenAFP-Utils, OptDir, PrimitiveArray, Pugs, SQLDeps, Spock, Spock-core, Unique, WordAlignment, ac-machine, accelerate, accelerate-cuda, accelerate-llvm-ptx, aeson, aeson-compat, aeson-diff, aeson-extra, aeson-native, airtable-api, amazonka-core, ampersand, analyze, anatomy, apiary, approximate, arith-encode, ascii, ascii-table, astar, atomo, audiovisual, aws-general, b9, bake, basic-prelude, betacode, bimaps, binary-orphans, binary-tagged, biohazard, bittorrent, bloodhound, bloomfilter-redis, bolt, boltzmann-samplers, bond-haskell, bound, btree-concurrent, buchhaltung, bytes, bytestring-plain, cabal-install, cache, call, case-insensitive, cassava, cereal-plus, cg, chatter, chronos, clang-pure, clash-ghc, clash-lib, clash-systemverilog, clash-verilog, clash-vhdl, classy-prelude, closure, codeworld-api, coinbase-exchange, compensated, composite-aeson, compressed, computational-algebra, concrete-haskell, concrete-typerep, concurrent-dns-cache, concurrent-supply, configurator, configurator-ng, constraints, cplex-hs, cql-io, csound-expression-dynamic, csound-expression-typed, ctrie, currency, darcs, data-dword, data-embed, data-interval, data-msgpack, data-msgpack-types, data-sword, datalog, datasets, delaunay, dense, detrospector, diagrams-builder, diagrams-cairo, diagrams-contrib, diagrams-lib, diagrams-pgf, diagrams-postscript, diagrams-rasterific, diagrams-svg, dingo-core, directed-cubical, discord-hs, discrimination, distributed-process, distributed-process-async, distributed-process-client-server, distributed-process-execution, distributed-process-extras, distributed-process-platform, distributed-process-registry, distributed-process-supervisor, distributed-process-task, dockercook, dustme, dvda, dynamic-loader, dynamic-pp, dynamic-state, dynamodb-simple, elsa, etc, euphoria, ex-pool, exference, exinst, exinst-hashable, expiring-cache-map, extended-reals, extensible-data, ez-couch, family-tree, fastedit, fca, fcache, fficxx, filecache, finite-field, fixfile, flowdock-rest, forbidden-fruit, forest, fpco-api, free-game, funbot, functor-classes-compat, fwgl, fwgl-glfw, fwgl-javascript, gact, genvalidity-hspec-hashable, ginsu, github, gitlib, glirc, glue, glue-common, glue-core, glue-ekg, glue-example, gogol-core, gore-and-ash, gore-and-ash-actor, gore-and-ash-async, gore-and-ash-demo, gore-and-ash-glfw, gore-and-ash-lambdacube, gore-and-ash-logging, gore-and-ash-network, gore-and-ash-sync, graph-core, graphene, grasp, hOpenPGP, hackport, hadoop-rpc, hamtmap, hans, hash, hashable-extras, hashable-generics, hashable-orphans, hashable-time, hashmap, hashring, hashtables, hashtables-plus, haskell-igraph, haskell-neo4j-client, haskhol-core, hasql, hasql-postgres, haxl, haxl-amazonka, haxl-facebook, hblock, heist, hit-graph, hjsonpointer, hjsonschema, hledger, hoodle-render, hsc3, hsc3-forth, hsc3-graphs, hsc3-lang, hsc3-lisp, hsc3-utils, hslua-aeson, hsoz, hspec-hashable, hspec-webdriver, hstzaar, http-api-data, huff, hydrogen-prelude, hyperloglog, hypher, identifiers, igraph, imm, impure-containers, inline-c, insert-ordered-containers, instant-hashable, intern, intro, ip, irc-core, irc-fun-client, irc-fun-types, json-autotype, json-fu, json-incremental-decoder, json-rpc, karps, keys, keyvaluehash, krapsh, language-eiffel, language-puppet, lattices, lens, lens-prelude, libconfig, libcspm, libsystemd-journal, linear, link-relations, linkedhashmap, linux-inotify, lio, liquid, liquid-fixpoint, liquidhaskell, llvm-analysis, llvm-base-types, llvm-data-interop, log-domain, log-warper, lrucaching, lua-bytecode, lucid, machines-amazonka, marquise, marvin, mealstrom, memcache, memcache-haskell, memorable-bits, mfsolve, microlens-platform, modular-prelude, mono-traversable, monoidal-containers, msgpack, mtgoxapi, muesli, multiaddr, multipass, nested-routes, network-dns, network-ip, network-transport, normalization-insensitive, notmuch-web, objective, ombra, once, open-witness, openflow, orgmode-parse, orgstat, path, persistent-audit, pg, pinch, plots, pointed, postgresql-simple, praglude, pred-set, pred-trie, pringletons, pseudo-boolean, psqueues, pugs-DrIFT, push-notify-general, pusher-http-haskell, pusher-ws, puzzle-draw, quick-schema, quickcheck-instances, range-set-list, rdf4h, reactive-banana, rebase, reducers, refcount, regex, regex-deriv, regex-examples, remotion, renderable, reroute, resolve, resource-pool, resource-pool-catchio, rest-gen, rest-stringmap, rethinkdb-client-driver, riak, rl-satton, rose-trees, safe-money, satchmo, sci-ratio, scientific, scrape-changes, scrz, second-transfer, selda, semigroups, seqloc, seqloc-datafiles, serialize-instances, serokell-util, servant-docs, servant-haxl-client, serversession, sets, shake, sign, signals, simple-css, simple-index, sized, sized-vector, slack-api, smallarray, smallstring, snap, snap-core, snap-cors, snap-templates, snaplet-auth-acid, snaplet-oauth, special-keys, sprinkles, stack, stackage-cli, stackage-curator, stackage-types, stash, static-hash, stm-containers, store, str, stratosphere, strelka, strelka-core, strict-base-types, structures, svg-builder, swagger2, swish, sym, t3-server, tables, tak, task-distribution, text-latin1, text-loc, these, threepenny-gui, thrift, tidal, time-warp, timemap, toysolver, tpdb, transf, transient-universe, tries, trifecta, ttrie, tttool, type-structure, uhc-light, uhc-util, unfoldable-restricted, uniplate, unique, universum, unjson, unordered-containers, unordered-containers-rematch, unordered-graphs, uuid-types, vault, vaultaire-common, vector-clock, vector-instances, vivid, vty, wai-middleware-content-type, wai-middleware-throttle, wai-middleware-verbs, warp, web-inv-route, webfinger-client, witherable, workflow-types, wreq, wreq-sb, xhb-atom-cache, xhb-ewmh, xml-to-json, yesod-continuations, yesod-static, yi-core, yi-language
comments powered byDisqus