How it works...
The INI parser is a combinatorial top-down recursive-descent parser. Its monad instance creates a composable function that can be run later with runParser with input. We used monad/Applicative and Functor to combine the parser combinatorially from smaller units such as char, quotedchar, quotedvalue, and so on until we build the whole INI file parser.
Every time we compose two parsers, we create a function that first runs one parser, evaluates its value and remaining input, and then invokes the second parser to again evaluate its value. Such nesting and sequencing of parsers gives rise to a composition of parsing functions. The resultant parser function can be run on input to get the desirable value.
The parser is diagrammatically ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access