Summary
In this chapter, we learned how parser combinators make it easy to turn strings into structured data. We covered how to write parsers and also looked under the hood of a minimal parser combinator implementation to get a basic understanding of how the approach works. Then, we moved on to the industrial-strength Parsec library for parser combinators. We studied its character consumption behavior and its support for error messages. Finally, we explored how to satisfy several requirements and avoid common pitfalls when writing parsers.
Chapter 15, Lenses, presents an elegant, purely functional approach to a mundane but ubiquitous programming task: data access in nested data types. First, we’ll identify the disadvantages of Haskell’s built-in support for record access and then present the concept of lenses as a much more convenient alternative for both reading and updating fields. We’ll not only show that lenses compose trivially to reach deep into data structures...