mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 19:58:18 +00:00
Merge remote-tracking branch 'remote/main' into builtin-json
This commit is contained in:
commit
e5dd4295c9
8 changed files with 224 additions and 27 deletions
|
@ -9,6 +9,7 @@ interface Hash
|
|||
addU32,
|
||||
addU64,
|
||||
addU128,
|
||||
hashBool,
|
||||
hashI8,
|
||||
hashI16,
|
||||
hashI32,
|
||||
|
@ -20,7 +21,7 @@ interface Hash
|
|||
hashList,
|
||||
hashUnordered,
|
||||
] imports [
|
||||
Bool.{ isEq },
|
||||
Bool.{ Bool, isEq },
|
||||
List,
|
||||
Str,
|
||||
Num.{ U8, U16, U32, U64, U128, I8, I16, I32, I64, I128, Nat },
|
||||
|
@ -70,6 +71,12 @@ hashList = \hasher, lst ->
|
|||
List.walk lst hasher \accumHasher, elem ->
|
||||
hash accumHasher elem
|
||||
|
||||
## Adds a single [Bool] to a hasher.
|
||||
hashBool : a, Bool -> a | a has Hasher
|
||||
hashBool = \hasher, b ->
|
||||
asU8 = if b then 1 else 0
|
||||
addU8 hasher asU8
|
||||
|
||||
## Adds a single I8 to a hasher.
|
||||
hashI8 : a, I8 -> a | a has Hasher
|
||||
hashI8 = \hasher, n -> addU8 hasher (Num.toU8 n)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue