Module Mhash
Modular Hashing interface.
This library exposes a hasher type that can be used to describe how to hash values of a given type, regardless of the concrete hash function used.
It is inspired by Rust's Hash trait.
A concrete hash function can be described using hash_algo, which is similar to Rust's Hasher trait.
See Mhash_fnv or Mhash_sha for concrete functions.
type ('ctx, 'output) hash_algo={}A hash algorithm, like murmur3, Sha1, FNV, etc.
- parameter 'ctx
the internal mutable context that contains the intermediate hashing state.
- parameter 'output
the result of hashing a value. It can be an integer but might be larger (e.g. 512 bits for SHA512).
type 'a hasher={hash_into : ctx out. ('ctx, 'out) hash_algo -> 'ctx -> 'a -> unit;}A hash function for a type
'a.It updates the given
ctxusing thehash_algocore functions and possibly otherhashervalues. This works for any concrete hash function that implementshash_algo.
val bytes : bytes hasherval string : string hasherval int : int hasherval nativeint : nativeint hasherval int32 : int32 hasherval int64 : int64 hasherval bool : bool hasherval char : char hasherval trivial : 'a hasherTrivial hasher, does nothing.
val option : 'a hasher -> 'a option hasherOption hasher. It calls
honxif the input isSome x, and also injects the constructor into the hash context.
val map : f:('a -> 'b) -> 'b hasher -> 'a hashermap ~f happlies hasherhtof xin order to hashx.
val iter : 'a hasher -> (('a -> unit) -> unit) hasherHash an iterator by applying the hasher to each element.
val seq : 'a hasher -> 'a Stdlib.Seq.t hasherHash a sequence of items by applying the hasher to each element.
val pair : 'a hasher -> 'b hasher -> ('a * 'b) hasherval tup2 : 'a hasher -> 'b hasher -> ('a * 'b) hasherval tup3 : 'a hasher -> 'b hasher -> 'c hasher -> ('a * 'b * 'c) hasherval tup4 : 'a hasher -> 'b hasher -> 'c hasher -> 'd hasher -> ('a * 'b * 'c * 'd) hasherval hash : algo:('a, 'output) hash_algo -> hash:'b hasher -> 'b -> 'outputHash a value using the given algorithm and type hasher.