Add Decode.mapResult

This commit is contained in:
Ayaz Hafiz 2022-10-18 14:39:35 -05:00
parent bb8888b115
commit e08b613047
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
2 changed files with 5 additions and 0 deletions

View file

@ -27,6 +27,7 @@ interface Decode
decodeWith,
fromBytesPartial,
fromBytes,
mapResult,
]
imports [
List,
@ -96,3 +97,6 @@ fromBytes = \bytes, fmt ->
Err TooShort -> Err TooShort
else
Err (Leftover rest)
mapResult : DecodeResult a, (a -> b) -> DecodeResult b
mapResult = \{result, rest}, mapper -> {result: Result.map result mapper, rest}

View file

@ -1518,6 +1518,7 @@ define_builtins! {
24 DECODE_DECODE_WITH: "decodeWith"
25 DECODE_FROM_BYTES_PARTIAL: "fromBytesPartial"
26 DECODE_FROM_BYTES: "fromBytes"
27 DECODE_MAP_RESULT: "mapResult"
}
13 HASH: "Hash" => {
0 HASH_HASH_ABILITY: "Hash" exposed_type=true