While taking the MOOC Introduction to Functional Programming by Erik Meijer on edX the current lecture greatly increased my interest in functional parsers. Functional parsers are about the essence of (functional) programming because they are about the concept of composition which is one of the core concepts of programming whatsoever.
The content of the lecture is closely related to the chapter 8 Functional Parsers of the book Programming in Haskell by Graham Hutton. It starts out with the definition of a type for a parser and a few very basic parsers.
I’m totally amazed by the simplicity, the elegance and the compositional aspect of these examples. I find it impressive how primitive but yet powerful these simple parsers are because they can easily be combined to form more complex and very capable parsers.
As an exercise, out of curiosity, and because of old habits I implemented the examples from the book in C#.
At the end of this post there will be an ultimate uber-cool parser example of a parser for arithmetic expressions.
The complete code from this post can be found here on GitHub.
Here is what I got:
Continue reading →