mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
Bool decoding
This commit is contained in:
parent
a00953128d
commit
c85c865b05
1 changed files with 9 additions and 2 deletions
|
@ -280,8 +280,15 @@ decodeDec = Decode.custom \bytes, @Json {} ->
|
|||
Ok n -> {result: Ok n, rest}
|
||||
Err _ -> {result: Err TooShort, rest}
|
||||
|
||||
# FIXME
|
||||
decodeBool = Decode.custom \bytes, @Json {} -> {result: Err TooShort, rest: bytes}
|
||||
decodeBool = Decode.custom \bytes, @Json {} ->
|
||||
{before: maybeFalse, others: afterFalse} = List.split bytes 5
|
||||
if maybeFalse == [ (asciiByte 'f'), asciiByte 'a', asciiByte 'l', asciiByte 's', asciiByte 'e' ]
|
||||
then {result: Ok False, rest: afterFalse}
|
||||
else
|
||||
{before: maybeTrue, others: afterTrue} = List.split bytes 4
|
||||
if maybeTrue == [asciiByte 't', asciiByte 'r', asciiByte 'u', asciiByte 'e']
|
||||
then {result: Ok True, rest: afterTrue}
|
||||
else {result: Err TooShort, rest: bytes}
|
||||
|
||||
# FIXME
|
||||
decodeString = Decode.custom \bytes, @Json {} -> {result: Err TooShort, rest: bytes}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue