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)

Preface

Functional programming has been gaining lot of momentum recently. We are seeing different paradigms of functional programming creeping into imperative languages such as C++, C#, and Python. There are languages such as Scala that try to offer best of both worlds, that is, object-oriented programming and functional programming.

As Haskell is a pure and non-strict language, and strictly separates pureness from effect-full computations, it really stands out among these languages. Its strong theoretical basis, such as an elaborate type system, combined with concise and expressive syntax, gives Haskell a unique flavor. It really helps in programming declaratively by specifying what rather than how! In this book, we will focus on practical aspects of the language.
Haskell Cookbook is meant for programmers who have a programming background. Most of the readers should be acquainted with an imperative language, such as Java/Python or C++.

This cookbook can be logically divided into two parts, the first five chapters serve as building blocks for programming in Haskell. These chapters cover syntactical and semantic details of the language by describing how to use and define functions and data types. In these chapters, we also cover type classes and the Functor, Applicative, and Monads concepts.
The last seven chapters will introduce you to the practical aspects of usage of Haskell and its rich set of libraries. These chapters will take you through containers in Haskell and backend development (developing with database) to frontend development (web framework). The last three chapters focus on advanced concepts, such as doing parallel and distributed programming in Haskell.

Each recipe is self-sufficient, and, wherever possible, the recipe will try to build a concept (such as Monad) from scratch, before moving on to a recipe that will use the concept from the existing library. This is especially true in the first five chapters.
Use this book to dive into Haskell and Functional Programming in general. Start building small toy programs by using recipes, and move on to bigger programs to create your own web application or a distributed system. Even if you are not planning to use Haskell in your day-to-day work, I can assure you that it will change the way you look at programming, even when programming with other languages.

This book is not possible without encouragements from my family and the constant pursuance and perseverance of the staff at Packt. These people believed in me even when I was delayed or transgressed.