Free Haskell Books

Master Haskell Programming with Free Books

Haskell Books

Haskell is a standardized, general-purpose, polymorphically statically typed, lazy, purely functional language, very different from many programming languages. Recent innovations include static polymorphic typing, higher-order functions, user-definable algebraic data types, a module system, and more. It has built-in concurrency and parallelism, debuggers, profilers, rich libraries and an active community, with approximately 5,400 third-party open source libraries and tools.

This is a mature programming language with the first version defined in 1990. It has a strong, static type system based on Hindley–Milner type inference. The main implementation of Haskell is the Glasgow Haskell Compiler (GHC), an open source native code compiler.

Haskell offers many advantages to programmers. It helps rapid application development with shorter, clearer code, and higher reliability. It’s suitable for a variety of applications, and often used in academia and industry.

The focus of this article is to select the finest open source Haskell books which help programmers master this language, and develop an in-depth understanding of the benefits that this programming language offers. All of the books are available to download without payment.

We publish a series covering the best open source programming books for other popular languages. Read them here.

Real World Haskell

Real World Haskell

By Bryan O’Sullivan, John Goerzen, Donald Bruce Stewart (714 pages)

Real World Haskell is an easy-to-use, fast-moving tutorial that introduces the reader to functional programming with Haskell.

The reader learns how to use Haskell in a variety of practical ways, from short scripts to large and demanding applications. Real World Haskell takes you through the basics of functional programming at a brisk pace, and then helps you increase your understanding of Haskell in real-world issues like I/O, performance, dealing with data, concurrency, and more as you move through each chapter.

Chapters cover:

  • Getting started
  • Types and functions – provides an overview of Haskell’s type system, and much of its syntax. It covers some common basic types, function application, useful composite data types: lists and tuples, functions over lists and tuples, function types and purity, Haskell source files and writing simple functions, understanding evaluation by example, and polymorphism in Haskell
  • Defining types, streamlining functions – build on this basic knowledge to further enhance our understanding of Haskell
  • Functional programming – a simple command line framework, a built-in function lines to split a text string on line boundaries, infix functions, working with lists, how to think about loops, anonymous (lambda) functions, partial function application and currying, as-patterns, and code reuse through composition
  • Writing a library: working with JSON data – develop a small, but complete, Haskell library
  • Using typeclasses – learn about the need for typeclasses and how to use them. The authors talk about defining their own typeclasses and then cover some of the important typeclasses that are defined in the Haskell library. Finally, the reader is showed how to have the Haskell compiler automatically derive instances ocf certain typeclasses for their types
  • Input and output – simple, standard-looking I/O, then discusses some of the more powerful options as well as provide more detail on how I/O fits into the pure, lazy, functional Haskell world
  • Efficient file processing, regular expressions, and file name matching
  • I/O case study: a library for searching the filesystem – develop a library that gives us many of find’s capabilities, without leaving Haskell. The authors explore several different approaches to writing this library, each with different strengths
  • Code case study: parsing a binary data format
  • Testing and quality assurance – how to use QuickCheck to establish invariants in code and then re-examine the pretty printer developed in previous chapters, testing it with QuickCheck. The authors also see how to guide the testing process with GHC’s code coverage tool: HPC
  • Barcode recognition – make use of the image parsing library developed in the code cast study to build a barcode recognition application
  • Data structures – looks at association lists, maps, and different data structures, with some extended examples
  • Monads – provide a powerful way to build computations with effects. This chapter illustrates how monads are useful tools to help solve practical problems
  • Programming with monads – including association lists, generalised lifting, and separating interface from implementation
  • The Parsec parsing library – a useful parser combinator library, with which we combine small parsing functions to build more sophisticated parsers
  • The foreign function interface – shows how the FFI adds a new dimension of flexibility to the language
  • Monad transformers – similar to a regular monad, but it’s not a standalone entity: instead, it modifies the behaviour of an underlying monad
  • Error handling – in Haskell, you will find two major types of error handling employed: “pure” error handling and exceptions
  • Systems programming – attempts a Perl-like “language” that is valid Haskell, implemented in pure Haskell, that makes shell scripting easy
  • Working with databases – introduces the reader to one of the Haskell frameworks for working with databases. The authors also use this framework to begin building a podcast downloader
  • Web client programming – develop a real application in this chapter: a podcast downloader, or “podcatcher”
  • GUI programming – looks at gtk2hs, one of several graphical user interface toolkits available for Haskell
  • Basic concurrent and parallel programming – harness the power of multicore systems via concurrent and parallel programming
  • Profiling and tuning for performance – looks at typical space and time problems a Haskell programmer might encounter, and how to methodically analyse, understand and address them
  • Advanced library design: building a Bloom filter – a set-like data structure that is highly efficient in its use of space
  • Network programming – discusses lower-level networking tools in the Haskell library
  • Software transactional memory

This work is licensed under a Creative Commons Attribution-Noncommercial 3.0 License.

Learn You a Haskell for Great Good!

Learn You a Haskell for Great Good!

By Miran Lipovača (400 pages)

Learn You a Haskell for Great Good! is an illustrated guide to this complex functional language. Packed with the author’s original artwork, pop culture references, and most importantly, useful example code, this book teaches functional fundamentals in a way you thought impossible.

Chapters cover:

  • Introduction
  • Starting Out – includes an introduction to lists, texas ranges, and tuples
  • Types and Typeclasses – understanding the type system
  • Syntax in Functions – explores some of Haskell’s constructs including pattern matching and let bindings
  • Recursion – takes a closer look at recursive functions, why they are important to Haskell and how we can work out very concise and elegant solutions to problems by thinking recursively
  • Higher-Order Functions – curried functions, maps and filters, lambdas, the foldl and foldr functions, the foldl1 and foldr1 functions, and the scanl and scanr functions, function application with $, function composition
  • Modules – a Haskell module is a collection of related functions, types and typeclasses. The chapter examines loading modules, Data.List, Data.Char, Data.Map, Data.Set, and making your own modules
  • Making Our Own Types and Type Classes – learn how to make your own Haskell types and typeclasses
  • Input and Output – examines files and streams, command line arguments, randomness, bytestrings and exceptions
  • Functionally Solving Problems – takes a look at a few interesting problems and how to think functionally
  • Functors, Applicative Functors and Monoids – takes a closer look at functors, along with slightly stronger and more useful versions of functors called applicative functors. The reader also explores monoids
  • A Fistful of Monads – learn about monads, which are beefed up applicative functors, much like applicative functors are beefed up functors
  • For a Few Monads More – learn about a few other monads. See how they can make programs clearer by letting us treat all sorts of values as monadic ones
  • Zippers – see how we can take some data structure and focus on a part of it in a way that makes changing its elements easy and walking around it efficient

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.

Developing Web Applications with Haskell and Yesod

Developing Web Applications with Haskell and Yesod

By Michael Snoyman (298 pages)

Developing Web Applications with Haskell and Yesod is a guide which introduces web application development with Haskell and Yesod, a potent language/web framework combination that supports high-performing applications that are modular, type-safe, and concise. The reader works with several samples to explore the way Yesod handles widgets, forms, persistence, and RESTful content. The reader also receives an introduction to various Haskell tools to supplement basic knowledge of the language.

After completing the book, the reader will have created a production-quality web application with Yesod’s ready-to-use scaffolding. Real-world examples, including a blog, a wiki, a JSON web service, and a Sphinx search server will have been examined.

Chapters cover:

  • Introduction – examines how Yesod aims to make web development easier by playing to the strengths of Haskell
  • Haskell – fills in some of the features of Haskell that are not covered in most introductory texts
  • Basics – gets the reader started with a simple Yesod application, and cover some of the basic concepts and terminology
  • Shakespearean Templates – use Shakespearean template languages for HTML, CSS, and Javascript output
  • Widgets – provide the glue that allows templates languages to work together. The chapter helps the reader understand how to construct and combine widgets, generate IDs, and understand type signatures
  • Yesod Typeclass – explores the meaning of many of the methods of the Yesod typeclass
  • Routing and Handlers – examines route syntax, pieces, types of pieces (static, dynamic single and dynamic multi), resource name, handler specification, dispatch, return type, arguments, the handler monad, application information, request information, short circuiting, and response headers
  • Forms – a way to validate data
  • Sessions & Persistent – learn how Yesod and Haskell store session data and handle persistence
  • Deploying your Webapp – build a simple application to learn Yesod’s foundation datatype and Web Application Interface (WAI)
  • Advanced:
    • RESTful Content – request methods: GET, POST, PUT, DELETE, representations, RepHtmlJson, news feeds, other request headers, stateless
    • Yesod’s Monads – monad transformers, the three transformers, example: database-driven navbar, example: request information
    • Authentication and Authorization – authentication deals with identifying a user, authorization determines what a user is allowed to do
    • Scaffolding and the Site Template
    • Internationalization
    • Creating a Subsite – a collection of routes and their handlers that can be easily inserted into a master site. Create reusable components for several applications with Yesod subsites
  • Examples
    • Blog: i18n, authentication, authorization, and database
    • Wiki: markdown, chat subsite, event source
    • JSON Web Service
    • Case Study: Sphinx-based Search

The book is available under the Creative Commons Attribution 4.0 International License.


PROGRAMMING LANGUAGE PROFILES

Ada, Awk, Assembly, Bash, C, C++, C#, Clojure, CoffeeScript, ECMAScript, Erlang, Forth, Fortran, Go, Haskell, HTML, Java, JavaScript, LaTeX, Lisp, Logo, Lua, OCaml, Pascal, Perl, PHP, Prolog, Python, R, Ruby, Rust, Scala, Scheme, Scratch, SQL, Swift, TeX, VimL

Leave a Reply