Book Image

Haskell Cookbook

Book Image

Haskell Cookbook

Overview of this book

Haskell is a purely functional language that has the great ability to develop large and difficult, but easily maintainable software. Haskell Cookbook provides recipes that start by illustrating the principles of functional programming in Haskell, and then gradually build up your expertise in creating industrial-strength programs to accomplish any goal. The book covers topics such as Functors, Applicatives, Monads, and Transformers. You will learn various ways to handle state in your application and explore advanced topics such as Generalized Algebraic Data Types, higher kind types, existential types, and type families. The book will discuss the association of lenses with type classes such as Functor, Foldable, and Traversable to help you manage deep data structures. With the help of the wide selection of examples in this book, you will be able to upgrade your Haskell programming skills and develop scalable software idiomatically.
Table of Contents (13 chapters)

Introduction

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...