Safe Haskell | None |
---|
Tools for working with StableTree keys. Just about anything can be a key, so long as there's a sane way to implement IsKey and the standard Ord class.
Typical users don't need to worry about anything here other than perhaps IsKey.
- class IsKey k where
- data Key t k
- data SomeKey k
- data Terminal
- data Nonterminal
- wrap :: IsKey k => k -> SomeKey k
- unwrap :: SomeKey k -> k
- hashSerialize :: Serialize t => t -> Word8
- hashBinary :: Binary t => t -> Word8
- hashByteString :: ByteString -> Word8
Documentation
Type class for anything that we can use as a key. The goal here is to wrap up a function that can generate a high-entropy eight-bit hash. Speed is somewhat important here, but since we only actually look at four bits of the hash, it really shouldn't be a problem to quickly generate sufficiently random data.
Implementors probably want to use hashSerialize
, hashBinary
, or
hashByteString
when writing their hash
functions.
A wrapper for keys; this has an ephemeral t
that will be either
Terminal
or Nonterminal
depending on the result of hash k
.
A sum type to contain either a Terminal
or a Nonterminal
Key
data Nonterminal Source
Used to indicate that a Key
is not terminal
hashSerialize :: Serialize t => t -> Word8Source
Calculate a hash for an instance of Serialize
hashBinary :: Binary t => t -> Word8Source
Calculate a hash for an instance of Binary
hashByteString :: ByteString -> Word8Source
Calculate a hash for a ByteString