Esc
Start typing to search...

Hash Module

Native implementations of hash : Hash a => a -> Int for all primitive types, plus the mulWrap helper used by deriving (Hash) enum bodies.

Functions

Hash.hashBool

Bool -> Int

Hash a Bool value: True hashes to 1, False to 0.

Hash.hashChar

Char -> Int

Hash a Char value using FNV-1a on its 4-byte UTF-32 (little-endian) encoding.

Hash.hashDecimal

Decimal -> Int

Hash a Decimal value by normalizing it and hashing its canonical byte representation.

Hash.hashFloat

Float -> Int

Hash a Float value using FNV-1a on its IEEE 754 bit pattern.

Notes: NaN values are canonicalized to u64::MAX before hashing so that all NaN bit patterns produce the same hash, preserving the invariant that equal values hash equally.

Hash.hashInt

Int -> Int

Hash an Int value using FNV-1a on its 8-byte little-endian encoding.

Hash.hashString

String -> Int

Hash a String value using FNV-1a on its UTF-8 bytes.

Hash.hashSymbol

Symbol -> Int

Hash a Symbol value using FNV-1a on its UTF-8 bytes.

Hash.mulWrap

Int -> Int -> Int

Multiply two Int values with wrapping semantics (no overflow error).

Notes: Used internally by deriving (Hash) enum bodies. The VM's * operator uses checked_mul and raises IntegerOverflow on overflow; wrapping arithmetic is correct for hash mixing.