Equations
- instHashablePos = { hash := fun (p : String.Pos) => UInt64.ofNat p.byteIdx }
Equations
- instHashableBool = { hash := fun (x : Bool) => match x with | true => 11 | false => 13 }
Equations
- instHashableUInt16 = { hash := fun (n : UInt16) => n.toUInt64 }
Equations
- instHashableUInt64 = { hash := fun (n : UInt64) => n }
Equations
- instHashableByteArray = { hash := fun (as : ByteArray) => ByteArray.foldl (fun (r : UInt64) (a : UInt8) => mixHash r (hash a)) 7 as }
Equations
- instHashableInt = { hash := fun (x : Int) => match x with | Int.ofNat n => UInt64.ofNat (2 * n) | Int.negSucc n => UInt64.ofNat (2 * n + 1) }
LawfulHashable α
says that the BEq α
and Hashable α
instances on α
are compatible, i.e.,
that a == b
implies hash a = hash b
. This is automatic if the BEq
instance is lawful.
If
a == b
, thenhash a = hash b
.