SETUP - You should have a basic understanding of Haskell (what data types, functions and type classes are) and have a working GHC installation. Clone and build these exercises
The default tool that many programmers immediately reach for when they wish to parse data (but don't want to deal with tools like Lex and Yacc) is regular expressions.
Of course, whenever you mention regular expressions, someone will bring up Jamie Zawinski. And now you have two problems.
However, regular expressions have many problems:
- They aren't composable
- They're typically represented as Strings rather than code making them harder to debug
- Often only interpreted at runtime leading to runtime failures (no static type checking!)
- They can't be used to parse HTML
The preferred approach in functional programming languages (also available in non-functional languages as well!) is parser combinators, which provide a way of writing your parser in code, thus being able to use all your existing tooling to do so.
In this workshop we will build up our own Parser Combinator library from scratch (and hopefully make sense of the dreaded M-word whilst we're at it!) and improve upon it, to see that there is nothing mystical about parsing in data.