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)

What this book covers

Chapter 1, Foundations of Haskell, introduces you to Haskell and helps you setup the environment for Haskell using the stack as a tool. In this chapter, you will write your first Haskell program, and then analyze its parts.

Chapter 2, Getting Functional, warms you up to Haskell by introducing recursion, maps, filters, and folds. It ends up by implementing a prime sieve.

Chapter 3, Defining Data, explores the rich data types that Haskell provides. You will be exposed to product and sum types. This chapter further introduces standard type classes in Haskell.

Chapter 4, Working with Functors, Applicatives, and Monads, dives deeper into Haskell by exploring the rich type classes and their instances. The recipes in this chapter allow the reader to build their own monad, and introduces IO monad.

Chapter 5, More about Monads, builds on the previous chapter by further creating and using monad transformers, and finally building a parser with Attoparsec.

Chapter 6, Working with Common Containers and Strings, looks at common containers and introduces Foldable and Traversals. In this chapter, you will also cook your own container and test it using Quickcheck. This chapter also looks at an alternate representation of String, that is, Text and ByteString.

Chapter 7, Working with Relational and NoSQL Databases, uses the Haskell based model declaration template and queries using persistent library. We will also use redis to work with NoSQL databases.

Chapter 8, Working with HTML and Templates, works with the Heist template framework along with the Blaze HTML library to create composable HTML documents.

Chapter 9, Working with Snap Framework, explores various web application development aspects, such as routing, templating, authentication, and sessions using the Snap Framework.

Chapter 10, Working with Advanced Haskell, introduces you to advanced concepts such as Existentially Quantified Type, Rank-N-Type, type family, and GADT.

Chapter 11, Working with Lens and Prism, explores the lens library to look at the concept of Lens and Prism. This chapter explains the concept of lens by building one itself. The rest of the chapter explains rich features of the Lens library.

Chapter 12, Concurrent and Distributed Programming in Haskell, introduces the building blocks of concurrent programming, such as IORef, MVar, and STM. The later part introduces Cloud Haskell to create distributed applications.