I just listened to Elm Radio Episode 6 - elm/parser. It was great! I’ve never used elm/parser myself (yet!) and would love to hear more from people who have.
elm/parser exposes two operators:
|=. Here’s an example from the docs:
point : Parser Point point = succeed Point |. symbol "(" |. spaces |= float |. spaces |. symbol "," |. spaces |= float |. spaces |. symbol ")"
It was interesting hearing how Dillon and Jeroen were “pronouncing” these operators! For example, around 14:40:
- “keep” … “– and discard?”
- “I was thinking there was a nicer four-letter word for both…”
- “Pipe-equals – like, vertical bar-equals operator – and there’s vertical bar-dot”
- “You do pipe-equals, or pipe-dot”
- “Pipe-equals is going to capture the result of that parser” … “and if you do pipe-dot [explanations about the fact that you expect certain characters, but are not keeping any data from them]”
This sparked two questions:
How do you pronounce them?
What if they weren’t actually operators, and instead were called like you pronounce them? For example:
point : Parser Point point = succeed Point |> skip (symbol "(") |> skip spaces |> keep float |> skip spaces |> skip (symbol ",") |> skip spaces |> keep float |> skip spaces |> skip (symbol ")")
Do you think the
|= operators make all the difference to making your parser readable, or are they more of a cute thing? (I’ve never used elm/parser myself, and as a bystander the
keep example looks just as readable.)