So far, we have looked at Haskell language features, type classes, and collections and worked with various examples. But all of those constructs were purely Haskell features. In this chapter, we will be interfacing with the outside world (apart from the console), by interacting with databases.
To be able to write a backend, or a storage service, it is imperative that we will at some time think about storing the data in a relational database, or a binary serializable format or a file such as JSON or YAML. In this chapter, we will use the persistent library to work with relational databases. Using the persistent model, we will define the relations, do a query, insert, update, and a deletion of the stored data. We will move on to Esqueleto for advanced queries. Esqueleto defines a DSL (Domain Specific Language) so that enables us to do advanced queries.
We will then...