I have the following:
module [parseNumber]
import JsonData
parseNumber : Str -> Result JsonData [InvalidNumStr, BadUtf8 _ _]
parseNumber = \input ->
Str.toU64 input
|> Result.map \n -> Number n
expect parseNumber "123" == Ok (Number 123)
I'm getting an error to say "Nothing is named JsonData
in this scope." on the return type of parseNumber.
I have my data type as a module, which exposes the tag union called JsonData
What am I doing wrong?
cheers :)
What is the name of the module containing JsonData
? I think you need to do import Module.JsonData
It's called JsonData.roc
module [JsonData]
JsonData : [
String Str,
Number I64,
Object (List (Str, JsonData)),
]
This is my module
I basically want to say my return type of parseNumber is Number
This seems to work:
module [parseNumber]
import JsonData exposing [JsonData]
# Alternative (if using `import` without `exposing`:
# parseNumber : Str -> Result JsonData.JsonData [InvalidNumStr, BadUtf8 _ _]
parseNumber : Str -> Result JsonData [InvalidNumStr, BadUtf8 _ _]
parseNumber = \input ->
Str.toI64 input
|> Result.map \n -> Number n
expect parseNumber "123" == Ok (Number 123)
thanks that worked!
Last updated: Jul 05 2025 at 12:14 UTC