Hey! I’m relatively new to Elm and I don’t have a ton of experience with Haskell, either, so forgive my newbiness here, but I’m trying to wrap my head around how the Parser module works. I really like the elegance of the syntax, but it seems a bit magical to me and I feel like if I understood how Elm read the code then it would at least unravel some of the mysteries behind this module.
Specifically, I came across this example in the Parser docs:
succeed identity |. keyword "let" |. spaces |= elmVar |. spaces |. symbol "="
What I’m curious about is how Elm actually parses this expression. I looked at the source code and noticed that
|= are defined as left-associative infix operators, with
|. taking higher precedence. I couldn’t find an exact source for this, but I’m also guessing that function calls take the highest precedence. With that in mind, is the following how Elm interprets this? (I realize that if you know the answer already, then the parentheses get in the way, but bear with me here.)
(((succeed identity) |. (keyword "let")) |. spaces) |= ((elmVar |. spaces) |. (symbol "="))
If that’s the case, can you interpret this as something like…?
|= (|. (|. (succeed identity) (keyword "let")) spaces) (|. (|. elmVar spaces) (symbol "="))