16 JSON and SQL
This chapter covers
- Parsing and serializing JSON
- Deriving typeclasses, using
Generic
- Using SQLite databases with our programs
In previous chapters, we have gotten to know many techniques and concepts in Haskell and built quite a few tools using them. Now, it is time to use everything we learned to realize a larger project. This and the following chapter function as a showcase for building an application with Haskell talking to a database and the network, providing a type-safe HTTP/JSON API. Additionally, we will automatically derive a client application for our API to safely interface with it. We will get to know a few new packages that will help us realize this.
This chapter starts with a discussion on working with JSON data using the aeson
library and how to generically derive type classes. Then, we will dive into using SQLite in our programs and how to pass data to and from the database. We will use this knowledge in the following chapter to construct our application.