Implement Json fromBytes without let-generalization

This commit is contained in:
Ayaz Hafiz 2022-07-27 12:25:49 -04:00
parent 3fdde9e8f0
commit 10ce5d0615
No known key found for this signature in database
GPG Key ID: 0E2A37416A25EF58

View File

@ -69,11 +69,11 @@ fromBytesPartial = \bytes, fmt -> decodeWith bytes decoder fmt
fromBytes : List U8, fmt -> Result val [Leftover (List U8)]DecodeError | val has Decoding, fmt has DecoderFormatting
fromBytes = \bytes, fmt ->
{ result, rest } = fromBytesPartial bytes fmt
if List.isEmpty rest then
when result is
Ok val -> Ok val
Err TooShort -> Err TooShort
else
Err (Leftover rest)
when fromBytesPartial bytes fmt is
{ result, rest } ->
if List.isEmpty rest then
when result is
Ok val -> Ok val
Err TooShort -> Err TooShort
else
Err (Leftover rest)