mirror of
https://github.com/roc-lang/roc.git
synced 2025-07-24 06:55:15 +00:00
Add Decode.mapResult
This commit is contained in:
parent
bb8888b115
commit
e08b613047
2 changed files with 5 additions and 0 deletions
|
@ -27,6 +27,7 @@ interface Decode
|
||||||
decodeWith,
|
decodeWith,
|
||||||
fromBytesPartial,
|
fromBytesPartial,
|
||||||
fromBytes,
|
fromBytes,
|
||||||
|
mapResult,
|
||||||
]
|
]
|
||||||
imports [
|
imports [
|
||||||
List,
|
List,
|
||||||
|
@ -96,3 +97,6 @@ fromBytes = \bytes, fmt ->
|
||||||
Err TooShort -> Err TooShort
|
Err TooShort -> Err TooShort
|
||||||
else
|
else
|
||||||
Err (Leftover rest)
|
Err (Leftover rest)
|
||||||
|
|
||||||
|
mapResult : DecodeResult a, (a -> b) -> DecodeResult b
|
||||||
|
mapResult = \{result, rest}, mapper -> {result: Result.map result mapper, rest}
|
||||||
|
|
|
@ -1518,6 +1518,7 @@ define_builtins! {
|
||||||
24 DECODE_DECODE_WITH: "decodeWith"
|
24 DECODE_DECODE_WITH: "decodeWith"
|
||||||
25 DECODE_FROM_BYTES_PARTIAL: "fromBytesPartial"
|
25 DECODE_FROM_BYTES_PARTIAL: "fromBytesPartial"
|
||||||
26 DECODE_FROM_BYTES: "fromBytes"
|
26 DECODE_FROM_BYTES: "fromBytes"
|
||||||
|
27 DECODE_MAP_RESULT: "mapResult"
|
||||||
}
|
}
|
||||||
13 HASH: "Hash" => {
|
13 HASH: "Hash" => {
|
||||||
0 HASH_HASH_ABILITY: "Hash" exposed_type=true
|
0 HASH_HASH_ABILITY: "Hash" exposed_type=true
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue