Equations
- instHashableNat = { hash := fun (n : Nat) => UInt64.ofNat n }
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
- instHashableUInt8 = { hash := fun (n : UInt8) => n.toUInt64 }
Equations
- instHashableUInt16 = { hash := fun (n : UInt16) => n.toUInt64 }
Equations
- instHashableUInt32 = { hash := fun (n : UInt32) => n.toUInt64 }
Equations
- instHashableUInt64 = { hash := fun (n : UInt64) => n }
Equations
- instHashableUSize = { hash := fun (n : USize) => n.toUInt64 }
Equations
- instHashableByteArray = { hash := fun (as : ByteArray) => ByteArray.foldl (fun (r : UInt64) (a : UInt8) => mixHash r (hash a)) 7 as }
Equations
- instHashableChar = { hash := fun (c : Char) => c.val.toUInt64 }
Equations
- instHashableInt = { hash := fun (x : Int) => match x with | Int.ofNat n => UInt64.ofNat (2 * n) | Int.negSucc n => UInt64.ofNat (2 * n + 1) }
Equations
- instHashable P = { hash := fun (x : P) => 0 }
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
.
Instances
@[instance 100]