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

Version on this page:
LTS Haskell 9.14:
Stackage Nightly 2017-11-23:
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.



  • Use typeRepFingerprint from Type.Reflection.Unsafe

  • Bump minimum version of base to 4.4.


  • 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 550 packages:
accelerate, accelerate-cuda, accelerate-llvm-native, accelerate-llvm-ptx, ac-machine, aeson, aeson-compat, aeson-diff, aeson-extra, aeson-injector, aeson-native, Agda, AhoCorasick, airtable-api, aivika-gpss, amazonka-core, ampersand, analyze, anatomy, apiary, approximate, arith-encode, arx, ascii, ascii-table, asn1-codec, astar, atomo, audiovisual, avro, aws-general, b9, bake, basic-prelude, betacode, bimaps, binary-orphans, binary-tagged, BiobaseInfernal, BiobaseTypes, BiobaseXNA, biohazard, bittorrent, blockchain, bloodhound, bloomfilter-redis, bolt, boltzmann-samplers, bond-haskell, bound, btree-concurrent, buchhaltung, bytes, bytestring-plain, cabal-install, cache, call, case-insensitive, cassava, Cassava, cereal-plus, cg, chatter, chronos, clang-pure, clash-ghc, clash-lib, clash-systemverilog, clash-verilog, clash-vhdl, classy-prelude, clingo, closure, codeworld-api, coinbase-exchange, compensated, composite-aeson, compressed, computational-algebra, concrete-haskell, concrete-haskell-autogen, concrete-typerep, concurrent-supply, ConcurrentUtils, configurator, configurator-ng, constraints, country, cplex-hs, cql-io, csound-expression-dynamic, csound-expression-typed, CTRex, ctrie, currency, CurryDB, darcs, data-dword, data-embed, data-interval, datalog, data-msgpack, data-msgpack-types, datasets, data-sword, Deadpan-DDP, 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, discord-rest, discord-types, 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, DSH, duckling, dumb-cas, dustme, dvda, dynamic-loader, dynamic-pp, dynamic-state, dynamodb-simple, elsa, EtaMOO, etc, euphoria, eventstore, exference, exinst, exinst-hashable, expiring-cache-map, ex-pool, extended-reals, extensible, extensible-data, ez-couch, family-tree, fastedit, fca, fcache, fficxx, filecache, fin, finite-field, fixfile, flowdock-rest, foldl, forbidden-fruit, forest, fpco-api, free-game, funbot, functor-classes-compat, fwgl, fwgl-glfw, fwgl-javascript, gact, gdax, genvalidity-hspec-hashable, genvalidity-unordered-containers, 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, graphite, grasp, hackport, hadoop-rpc, hamtmap, hans, hash, hashable-extras, hashable-generics, hashable-orphans, hashable-time, hashmap, hashring, hashtables, hashtables-plus, haskell-igraph, haskell-lsp, haskell-neo4j-client, haskey-btree, haskhol-core, haskus-system-build, hasql, hasql-postgres, HaTeX, haxl, haxl-amazonka, haxl-facebook, hblock, hCM, heist, hit-graph, hjsonpointer, hjsonschema, HLearn-algebra, HLearn-classification, hledger, HMap, hoggl, HongoDB, hoodle-render, hOpenPGP, hsc3, hsc3-forth, hsc3-graphs, hsc3-lang, hsc3-lisp, hsc3-utils, HSet, hslua-aeson, hsoz, hspec-hashable, hspec-webdriver, hstzaar, http-api-data, huff, HUnit-Plus, hw-kafka-avro, hydrogen-prelude, hyperion, 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, json-tracer, JunkDB-driver-hashtables, karps, keys, keyvaluehash, krapsh, LambdaHack, language-eiffel, language-ninja, language-puppet, lattices, lazy-hash, lazy-hash-cache, lens, lens-prelude, LibClang, libconfig, libcspm, libsystemd-journal, linden, linear, LinguisticsTypes, linkedhashmap, link-relations, 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, MagicHaskeller, mallard, marquise, marvin, matterhorn, mattermost-api, mealstrom, memcache, memcache-haskell, memorable-bits, mercury-api, mfsolve, microlens-platform, modular-prelude, monad-metrics, monoidal-containers, mono-traversable, msgpack, mtgoxapi, MuCheck, muesli, multiaddr, multipass, MutationOrder, nakadi-client, Neks, nested-routes, network-dns, network-ip, network-transport, noether, normalization-insensitive, notmuch-web, NXTDSL, objective, ombra, once, OpenAFP, OpenAFP-Utils, openflow, open-witness, OptDir, orgmode-parse, orgstat, path, pdf-slave-server, perfect-hash-generator, persistent-audit, pg, pg-store, pinch, plots, pointed, postgresql-simple, praglude, pred-set, pred-trie, PrimitiveArray, pringletons, profiterole, project-m36, prometheus-effect, propellor, protolude, pseudo-boolean, psqueues, Pugs, pugs-DrIFT, pusher-http-haskell, pusher-ws, push-notify-general, puzzle-draw, quantification, quickcheck-instances, quick-schema, 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, scientific, sci-ratio, scrape-changes, scrz, second-transfer, selda, semigroupoids, semigroups, semiring-num, seqloc, seqloc-datafiles, serialise, 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, snaplet-auth-acid, snaplet-oauth, snap-templates, special-keys, spiros, Spock, Spock-core, sprinkles, SQLDeps, stack, stackage-cli, stackage-curator, stackage-types, stash, static-hash, stm-containers, store, str, stratosphere, strelka, strelka-core, strict-base-types, strict-data, strict-types, structures, super-user-spark, svg-builder, svg-builder-fork, swagger2, swish, sym, t3-server, tables, tak, task-distribution, teleshell, TeX-my-math, text-latin1, text-loc, text-short, these, threepenny-gui, thrift, tidal, timemap, time-warp, tmapchan, tmapmvar, toysolver, tpdb, transf, transient-universe, trasa, tree-diff, tries, trifecta, ttrie, tttool, type-structure, uhc-light, uhc-util, ulid, unfoldable-restricted, uniplate, unique, Unique, universum, unjson, unordered-containers, unordered-containers-rematch, unordered-graphs, util-plus, uuid-types, validity-unordered-containers, validity-vector, vault, vaultaire-common, vec, vector-clock, vector-instances, versions, vintage-basic, vivid, vty, wai-middleware-content-type, wai-middleware-throttle, wai-middleware-verbs, warc, warp, webfinger-client, web-inv-route, websockets-rpc, weeder, witherable, WordAlignment, wreq, wreq-sb, xhb-atom-cache, xhb-ewmh, xml-to-json, yesod-continuations, yesod-static, yi-core, yi-language
comments powered byDisqus