mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-01 15:51:12 +00:00
Simpl decoder a bit
This commit is contained in:
parent
e08b5fa91e
commit
4a623a48dc
2 changed files with 27 additions and 6 deletions
|
@ -292,9 +292,10 @@ fn decode() {
|
|||
fromBytes = \lst, fmt ->
|
||||
when decodeWith lst decoder fmt is
|
||||
{ result, rest } ->
|
||||
when result is
|
||||
Ok val -> if List.isEmpty rest then Ok val else Err (Leftover rest)
|
||||
Err e -> Err e
|
||||
Result.after result \val ->
|
||||
if List.isEmpty rest
|
||||
then Ok val
|
||||
else Err (Leftover rest)
|
||||
|
||||
|
||||
Linear := {}
|
||||
|
@ -309,9 +310,8 @@ fn decode() {
|
|||
|
||||
# impl Decoding for MyU8
|
||||
decoder = @Decoder \lst, fmt ->
|
||||
when decodeWith lst u8 fmt is
|
||||
{ result, rest } ->
|
||||
{ result: Result.map result (\n -> @MyU8 n), rest }
|
||||
{ result, rest } = decodeWith lst u8 fmt
|
||||
{ result: Result.map result (\n -> @MyU8 n), rest }
|
||||
|
||||
myU8 =
|
||||
when fromBytes [ 15 ] (@Linear {}) is
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue