How do I convert a Str to a Num? I see various F64 and Nat's, but not sure how to get a Nat to an Int or Num.
Oh wait, disregard, this worked Str.toNat "10" |> Result.map \value -> value + 1
I guess I can treat Nat as an Int, ya? Helpful.
There are a large number of Str -> Num
methods of the form toI8, toI16,
etc: https://www.roc-lang.org/builtins/Num#toI8
There's nothing that goes from Str -> Num *
though - you have to parse into a concrete number type
Last updated: Jul 05 2025 at 12:14 UTC