In the Parser example, there is a function ParserStr.digits
. It parses an integer. However, it treats the parsed digits as their unicode codepoint (char 0 is 48 etc). However, because it tries to turn it into a decimal number, the result it wrong (e.g. the string '10' would be interpreted as 10 * 49 + 0 * 48
instead of 10 * 1 + 0 * 0
. I think the function should either return the correct decimal number (and maybe be renamed to int
?), or it should return a list of digits, so the user can choose what to do with them.
What do you think it should do? I'd be happy to do the fix
Good catch @Kilian Vounckx! Let's go with returning the correct decimal number and renaming it to positiveInt
since -1
is not yet supported. Feel free to ask me for review
Do I do it in the examples
repo, or in the main roc
repo? It has the same issue
Let's fix it in both, the duplication is not ideal but I can't think of a better solution.
Done in the main repo. It was already duplicate work there, as there is a package example as well as an interface not in a package
And done in the examples repo
@Anton The PR's are submitted. I am still running the tests in the main repo. I ran roc check on the files I changed though, so I don't think the tests will fail
Thanks @Kilian Vounckx I'll check it out in a bit :)
Last updated: Jul 05 2025 at 12:14 UTC