Hi. Really beginner question. Why am I getting error here?
walk_try_with_index :
List elem,
state,
(state, elem, U64 -> Result state err)
-> Result state err
walk_try_with_index = |list, state, f|
list
|> List.walk_try(
{index: 0, state},
|compound_state, elem|
Ok(
{
index: compound_state.index + 1,
state: f(compound_state.state, elem, compound_state.index)!,
}
)
)
|> Result.map_ok(.state)
Error:
UNFINISHED PARENTHESES
I am partway through parsing a record pattern, but I got
stuck here:
10│ |> List.walk_try(
11│ {index: 0, state},
12│ |compound_state, elem|
^
I was expecting to see a closing parenthesis next, so try
adding a ) and see if that helps?
I really can not understand what is wrong here. Is there a chance the compiler messes with me?
Hi @Ilya Shmygol,
The !
needs to be a ?
state: f(compound_state.state, elem, compound_state.index)!
So:
state: f(compound_state.state, elem, compound_state.index)?
I think we want to deprecate that old use of !
, I'll check on that
Thanks @Anton, it was it.
Yeah, the error message was really distracting here
Last updated: Jul 06 2025 at 12:14 UTC