Deriver for standard hash functions without extra dependencies.
opam install ppx_deriving_hash
In dune:
(preprocess (pps ppx_deriving_hash))
- Use
[@@deriving hash]
after a type definition to derive the functionval hash: t -> int
for it (if the type is namedt
) orval ty_hash: ty -> int
(otherwise if the type is namedty
). - Use
[@hash fun x -> ...]
after a type expression to override the underlying hash function used for it. - Use
[%hash: ty]
as an expression for the hash function of typety
.