Building a File Archiver
Now that we’ve had a chance to see several different examples of how we can use monad transformers, let’s try to put it together into a more useful example. In this section, we’ll build a utility that will let us create archives of files. Along the way, we’ll look for some opportunities to refine our approach to our monad transformer definitions to improve their ergonomics.
Our application allows users to define a file archive using a small language that we’ll parse. The language will let our users create a new archive, add items to the archive by importing files from disk, and add items by defining them inline. Here’s an example of an archive with three files:
| archive "example.archive": |
| |
| import "./example1.txt" ... |
Get Effective Haskell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.