app [main!] { pf: platform "./platform/main.roc" }
import pf.Stdout
main! = || {
# fails
#Stdout.line!(Str.inspect(question_fail(["1", "not a number", "100"])))
# works
Stdout.line!(Str.inspect(this_works(["1", "not a number", "100"])))
}
# question_fail : List(Str) -> Try(Str, _)
# question_fail = |strings| {
# first_str = strings.first()?
# Ok(first_str)
# }
this_works : List(Str) -> Try(Str, _)
this_works = |strings| {
first_str_res = strings.first()
first_str_res
}
Uncommenting yields:
❯ ./zig-out/bin/roc test/fx/hello_world.roc --no-cache
-- TYPE MISMATCH ---------------------------------
This expression is used in an unexpected way:
┌─ test/fx/hello_world.roc:15:17
│
15 │ first_str = strings.first()?
│ ^^^^^^^
It has the type:
List(Str)
But I expected it to be:
{ unknown: _field }
Found 1 error(s) and 0 warning(s) for test/fx/hello_world.roc.
Uncommenting yields: