Evan Czaplicki. 2020. Elm Parser. page
⇒ Backtracking ⇒ Semantics page ⇒ How Different Parsers Fit Together
~
Regular expressions are quite confusing and difficult to use. This library provides a coherent alternative that handles more cases and produces clearer code. github , page
⇒ Elm Radio Episode #6 elm/parser podcast
I mean, when you're working with Elm and you can parse things and then having parsed into a nice data structure, you can then use that data structure in Elm and do case statements on this well defined data type. elm-radio
You expect some kind of order, some kind of syntax. elm-radio
And if those expectations are not met, then you have a parsing failure.
That is a really great point. And that's a great way to frame the distinction.
00-08-46 – And so parsers are very different because parsers, you're going through one character at a time and eating the symbols to define what the structure of the content is.
00-20-08 – as soon as you chomp a value, as soon as you eat a character, you've committed down that path.
00-25-37 – And then the whole decoder fails. And that's for performance reasons. So what do you do instead?
00-28-08 – You know, a one of list that contains each of those parsers. Instead of that, you're going to say try parsing it as an integer or float.
textOrLink
00-36-11 – Start with a hard coded success, get your tests passing as fast as possible. I mean, this is the basic sort of TDD concept of, you know, fake it till you make it where you make it dumb, then make it smarter.
00-44-43 – So now your data is start set, end set, plus whatever expression data structure you had.
00-46-32 – So I think of it kind of like a fold expression in Elm where you can do like list dot fold L where like compared to list dot map list dot map,
00-51-36 – So in Elm parser terminology, that's a dead end.
context from loop
01-02-21 – Martin Janacek has his Elm in Elm compiler, which is not fully completed, still a work in progress, but that's something to check out and you can look at his talk on that at Elm Europe.