Fix Parser example

This commit is contained in:
Richard Feldman 2024-01-17 21:53:21 -05:00
parent 88ea8ffb67
commit fb82c09ac2
No known key found for this signature in database
GPG key ID: F1F21AA5B1D9E43B
2 changed files with 6 additions and 4 deletions

View file

@ -35,8 +35,9 @@ strToRaw = \str ->
strFromAscii : U8 -> Str
strFromAscii = \asciiNum ->
Str.fromUtf8 [asciiNum]
|> Result.onErr \_ -> crash "The number $(asciiNum) is not a valid ASCII constant!"
when Str.fromUtf8 [asciiNum] is
Ok answer -> answer
Err _ -> crash "The number $(Num.toStr asciiNum) is not a valid ASCII constant!"
strFromCodeunit : U8 -> Str
strFromCodeunit = \cu ->

View file

@ -45,8 +45,9 @@ strToRaw = \str ->
strFromAscii : U8 -> Str
strFromAscii = \asciiNum ->
Str.fromUtf8 [asciiNum]
|> Result.onErr \_ -> crash "The number $(asciiNum) is not a valid ASCII constant!"
when Str.fromUtf8 [asciiNum] is
Ok answer -> answer
Err _ -> crash "The number $(Num.toStr asciiNum) is not a valid ASCII constant!"
strFromCodeunit : U8 -> Str
strFromCodeunit = \cu ->