What's new
New in Functortown: An applicative Map

In this lesson we look at why an important data structure called Map is not a valid instance of Applicative. We consider an alternative to Map alongside Map itself, what their instances would look like, and the problem with pure. This involves discussion of one of the Applicative laws.

The Interactive Compiler

This series gives a comprehensive introduction to basic GHCi commands and usage.

The Compose newtype

In this addition to the Applicative section of the Functortown series, we continue our discussion of applicative functor composition by introducing the Compose newtype and then conclude with an example of using DerivingVia.

Introduction to GHC Extensions Series

This series begins with an introduction to GHC extensions, what they are and how to use them. That page is connected to a series of articles about the 12 extensions we think are most useful for Haskell beginners to learn, from NoImplicitPrelude through standards such as TypeApplications and ScopedTypeVariables through more controversial recommendations such as GADTSyntax and QuasiQuotes.

Updates to Partial type signatures

We’ve expanded the partial type signatures lesson. It discusses what kinds of things can be inferred with the extension, how it interacts with StandaloneDeriving, NamedWildCards, and ScopedTypeVariables, and how to suppress the warning that it emits.

New lesson in the Applicative series: Applicatives compose

After a brief look at IO as an applicative functor, we explore what it means that functors compose, paying special attention to the useful and common composition of Reader and IO.

New lesson in the GHCi series: :main and :run

The :main command in GHCi runs your program’s main action. But did you know that you can also pass it command-line arguments, that the action doesn’t have to be named main, and that you can do the same thing using the withArgs function?

New Phrasebook entry: Folding lists

Folding: A common task, and a common first step on the road to thinking functionally! Thanks to Jesus E. Gutierrez for submitting the initial code to the Phrasebook GitHub repository.

Stack and Nix

While Chris has previously written about the ways in which Stack and Nix are competing tools, we’ve found ourselves a few times using Stack and Nix, together. This article provides some tips for using Stack’s Nix integration when installing GHC or native (non-Haskell) dependencies.

New Phrasebook entry: A monitoring server

A monitoring server demonstrates using queues to communicate between threads, and using sockets to communicate between processes. This page in the Haskell Phrasebook covers a more complete and realistic program than the others we’ve written so far, and so it is a good bit longer than the rest.

Applicative lesson 5: The Reader context

The Applicative series continues its study of the notion of applicative functors as contexts for computation. Previously we talked about the Functor for the function type – or, more precisely, for (->) a, the partially applied function type. In this lesson we again discuss functions, this time looking at the Applicative instance often referred to as reader.

New Phrasebook entry: Moments in time

A lot of software has to deal with time in some form or another. Moments in time covers basic parsing and conversion operations for UTC times and Unix timestamps. Thanks to Taylor Fausak for submitting this example code during Hacktoberfest!

Atypical data constructors

We’ve been giving a lot of thought lately to how to present some of the more exotic language extensions – like GADTs, type families, and rank-N types – and we’ve decided to start by focusing not on the individual extensions one at a time, but rather with the more broad aim of “getting a more sophisticated understanding of the type system.” We still plan to make a reference page for each extension, but the more important place to start if you’re entirely unfamiliar with these features will be the new atypical data constructors series. It begins with a lesson on type equality constraints, which will then lead naturally into understanding what GADTs are and what they’re useful for.

Updates to the Validation course

We’ve added two new lessons to the the Validation course, thus making all of the book’s content available to Type Classes members. One lesson is about using coerce safely and effectively for newtype-heavy code, while the other is an introduction to the lens library through the prisms in the validation package.

New lessons in two courses!

This week, we’ve added content to two of our courses, Functortown and Validation. The Functortown lesson is called Zippy applicatives and discusses the two list applicatives: the normal one, and ZipList. Second, as many of our subscribers are aware, we had turned the Validation course into a book, and we made that free to anyone who was subscribed to Type Classes at the time when we published the book. The book included two chapters that did not appear on the site, however. The first of those, now added to the course, is on Coercible. We expect to add the final chapter next week, so all that content will be available to all our subscribers. Enjoy!

New posts in the Phrasebook and the GHCi series

We’ve received a number of great Hacktoberfest contributions to the Phrasebook. So far, we’ve added two new pages of free content as a result. A few days ago, we released an introduction to defining functions, and today we added a page on enum ranges. Many thanks to all who have contributed so far – we have several new pages in the works thanks to the contributions we’ve received. Also today we’ve added some content to our GHCi series. To the page on querying type information, we added information about using the :kind command. We also added a whole new page about the :info command.

Happy Hacktoberfest!

We have decided to open the Haskell Phrasebook to community contributions. We especially encourage contributions from people who have never contributed to a Haskell project before but would like to.

New Phrasebook entry: Inverting functions

Often we find ourselves needing a pair of related functions: 1. to encode some simple sum type as a string; 2. to parse a string back into that type. We show a simple pattern you can follow, with the help of GHC generics, to conveniently express this sort of bidirectional mapping.

New Phrasebook entry: Dynamic typing

In Haskell, all types are known statically at compile time. Or are they? We don’t use Dynamic, but we don’t like to say that Haskell can’t do something. If you want dynamic typing, here you go!

New Phrasebook entry: Cryptographic hashing

Since we had a Phrasebook entry for the hashable library, it seemed appropriate to add a page on cryptonite to emphasize the contrast between regular hash functions and cryptographic hash functions. This also gave a good place to demonstrate some simple string conversions: encoding and decoding in UTF-8, and representing a byte string in hexidecimal.

New lesson of Functortown

Functortown is back with a lesson on the rest of the Applicative class, the two “bird operators,” (<*) and (*>). Through three examples, we explore the sequencing role these operators play, as well as what “effects” means in the context of applicative functors. The final example is a small parsing program that showcases the utility of sometimes just throwing away your return values.

Python iterators: A Big Finale

Today we add five new pages to the series on iterators, bringing the total up to 11 pages and completing the series. These pages now cover the majority of the Python itertools module. If you’ve been following along with this, the new content begins with the take while lesson. We’re looking forward to adding more Python content in the future, but that’s a wrap on iterators!

Featured function: Rounding

The standard library for GHC Haskell includes at least four functions that perform a basic function we might describe as rounding. This entry in our Featured Function series provides explanation and examples to clarify how they are different from each other.

Haskell art: A really magnificent Mandelbrot

The header art for the Validation course depicts a portion of the Mandelbrot set. We’ve written a lengthy discussion of the Haskell code that generated the image originally written by Cies Breijs, and how we have modified it to add color. Check it out to learn about chaos, the Complex type, and the JuicyPixels graphics library.

Introducing the Haskell Phrasebook

We are excited to announce The Haskell Phrasebook. Taking an approach similar to Go by Example, it emphasizes how to get started writing programs quickly. In a departure from our usual style, this project does not explain everything in full detail; the Phrasebook’s role is only to be a traveler’s starting point and quick reference.

Using Nix as a Makefile

One of our first video series was about how we run Type Classes on Amazon EC2 using NixOS. We’re starting to expand our Nix content a bit more now, with some introductory discussion of what Nix is, and a comparison between a Nix file and a Makefile which if you’re familiar with Make will help convey what you might use Nix for.

Haskell art: the Julia set

You may have noticed some recent colorful additions to our page headers, such as on the Validation and Web servers courses. More than mere decorations, these are also Haskell demonstrations! We have discussions of how they were generated in our Art section. Today we’ve added a page on the Julia set that you see at the top of our home page, produced using the fractal-hs package.


The reference series on algebras that began with Semigroup has escalated to Semiring. We’ve given the semiring page an extensive update that includes a more in-depth discussion of tropical semirings and some useful thoughts on why you might care about the semiring of types.

Python data classes and Haskell records

This Python lesson discusses a decorator called dataclass. The primary role of a Python data class is to simply hold the values that were passed as constructor arguments. This feature strongly resembles Haskell datatypes, particularly when we use Haskell’s record syntax.

A spoonful of Enum

We’re writing the Python course in a slightly different style from most of Type Classes, because it is aimed at a more focused audience. The idea is that if you are already familiar with Python, then we want to leverage as much of your existing Python knowledge as possible as you learn Haskell. For example, we’re not including quite as many type signatures in our explanations as we normally would, and we defer the introduction of some aspects of Haskell to minimize the amount of patience required if you just want to answers to questions of the form ‘I know how to do this thing in Python; how do I do it in Haskell?’ This post is about one particular small choice regarding range syntax.

The zip function in Python and Haskell

The latest Python lesson is all about zipping, a notion also sometimes referred to as aligning. We discuss three Python functions: zip, zip_longest, and enumerate. The Haskell translations of the examples involve the these package, which we’ve discussed previously in Functortown.

Our one-year anniversary celebration

Type Classes has been in business for a year. To celebrate and share our success, annual memberships are half-off through June 30.

Forward and back buttons

Quick site design update: We’ve added navigation buttons at the top of pages that are part of a series.

New: Monoid

A monoid is a type along with a binary associative operation and an identity element. We’ve written a comprehensive guide to monoids in Haskell.

Update: Using wildcards in type applications

Our guide to the many uses of underscore has been amended to include its usage with the type applications extension, which does not also require enabling partial type signatures.

New: map in Python and Haskell

The Python course continues with a discussion of map (with one iterator argument, or with multiple) and itertools.starmap. Again the Haskell is very similar, with mostly superficial differences resulting from Python’s arity-based overloading.

Update: Semigroup newtypes

We added documentation for the newtypes in the Data.Semigroup module, and with that the semigroup page is done.

New: itertools.chain

To concatenate two Python iterators, we use chain. The corresponding Haskell function is (++). The chain function is variadic, whereas the (++) function is an infix operator; both are fine ways to make nested application more convenient.

New: Iteration to infinity in Python

The latest lesson in the Python course is about functions that produce simple never-ending iterators. The ability to represent concepts like “counting upward from one” and “repeating an item indefinitely” is a big part of what distinguishes iterators from lists in Python. In Haskell we describe things like Python iterators as “lazy” because elements are not evaluated until they are needed. Python lists, in contrast, we describe as “strict”.

New: Iterator slicing in Python

We previously discussed in the iterators lesson how Python iterators relate to Haskell lists. If you’re familiar with the itertools module, these next lessons will help you get started quickly with Haskell’s Data.List module. We begin with a discussion of islice.

New: Semigroup

A semigroup is a type together with a closed associative binary operation.

Python and the Monoid in the Applicative

We’ve added an article comparing Python iterators to Haskell lists. There’s also a new lesson of Functortown. Lesson 9, You got monoids in my functors!, goes further into Applicative functors. This lesson is supplemented by a reference page on Semigroup.


This week’s theme is applicative functors. The eighth lesson of Functortown is called Mapping a Maybe function; it starts off with a concise practical example that brings the Maybe applicative to our attention. We’ve also written the reference page on the ApplicativeDo extension.

Web Servers lesson 13

The thirteenth and final lesson of the Web Servers course is out today! It introduces pipes. Our latest featured function is null.

Featured functions

We just started a new section of the site called “Featured functions” which will house quick overviews of functions that we think deserve some extra love and attention. The first two featured functions are mapMaybe and intercalate.

Web Servers lesson 12 is about connection persistence – reusing the same socket for multiple HTTP requests. We write two versions of the server, one using lazy I/O and the other using strict ByteStrings.

Coercion and datatype contexts

Two new reference pages: A lengthy discussion of the coerce function, what it’s for, and how to use newtypes more effectively; and a note of historical interest on datatype contexts which addresses a common beginner question about typeclasses.

Object oriented Haskell

We have new lessons in two of our ongoing courses. In the fourth installment of the Timepieces course, Julie examines how the hierarchy of fltkhs is meant to mirror that of FLTK. The latest lesson in the Web Servers course is about parsing message bodies. And we’ve added to our documentation of GHC language extensions with an article on NumericUnderscores.

Return of the Clocks

This week we’re excited to bring you a new lesson in the native GUI course. In this lesson, Chris uses gtk3, Pango, and TVars to transform the blank application window into a clock. And the latest lesson in the Functortown course, in which Julie introduces the laws of the Bifunctor class and goes into more detail about how ranges and shrinkage work when you’re property testing with hedgehog.

Align, These, and HTTP headers

Course updates: Functortown lesson 6, More than a sum; Web Servers lesson 10, Interpreting request headers.


Learn to love deriving: deriving strategies, stock deriving extensions, the via strategy, and why instance deriving is important when using monad transformers.

Coupons for Finding Success

Everyone who has an active Type Classes subscription as of today can get the book for free on Leanpub; check your account page under the section entitled “Leanpub coupons”. The link can be used twice, so you can give a copy to a Haskell-curious friend.

Underscores and request parsing

We’ve released Web Servers lesson 9, Parsing requests, which continues our study of HTTP and gives a practical introduction to Attoparsec. We also continue to show how to ask GHCi for help with guides for using the beloved typed holes feature, all the uses of underscores, and warnings related to unused values.

Rigid types and block arguments

Type Classes now supports annual subscriptions and country-based discounts. We’ve added pages on rigid type variables and BlockArguments.

Stripe Haskell packages

This week we made some billing changes: There’s now an annual billing option in addition to monthly, and we now offer region-based discounts. We also took some time to publish a lot of the code that we use to work the Stripe API. You can find the code in the typeclasses/stripe repository on GitHub.

Covariance and GUIs

This week, more reference pages and new lessons in two of our ongoing courses! Topics include: Threads, levity polymorphism, pattern type signatures, bimap, POSIX signal handling, drawing with Cairo.

Clock and reference

We start our new series, Timepieces, with getting started with fltkhs. In Functortown lesson 4, breaking the laws!, Julie introduces using the Hedgehog library. We also have an overview of parsing libraries, an intro to concepts related to primitives, and more reference pages.

Almost Time

This week we released the third lesson in Functortown, Laws and orders, and the eighth lesson in Web Servers, The Never-ending response, and announce the beginning of a new course.

The Lessons Continue

This week we released the second lesson in Functortown, More common functors, and the seventh lesson in Web Servers, Chunking the message body.

A New Course Begins

This week we are beginning the Functortown course, a complete introduction to all kinds of functors. We also have added two new lessons in the Web Servers course since our last blog post, and we added a site index so the tags on posts are now clickable!

Intro to Template Haskell

Our first Template Haskell article focuses on one narrow use case: Compile-time evaluation of constant expressions. Because we care dearly about avoiding sources of runtime errors wherever possible.


We’ve restructured the site to make it easier to find content, added two JavaScript articles (one, two), and published some packages to Hackage. What’s next: Starting the Functortown course and continuing the Web Servers course.

GHCi helps those who help themselves

Julie presented a workshop on maximizing the useful information you can get from GHCi. It wasn’t recorded, but we’re working on getting all that information onto the site for our subscribers.

The various forms of Text and ByteString

Check out our new Haskell tip, entitled Strict, lazy, and builder – It covers the various string types in the text and bytestring packages.

C∘mp∘se :: Melbourne

Julie gave the keynote at C∘mp∘se :: Melbourne and we launched our new career as Haskell pamphleteers!

Web servers course

We’ve started releasing the web servers course, which will explain a lot about HTTP and how to write network applications in Haskell.

Finishing the first course

I chose the “Validation” course to be our flagship course on Type Classes because it’s material I’ve tested with meetup groups. Taking the same starting point as one of my more popular blog posts, it successively refactors relatively simple code until we’ve learned about several of Haskell’s most important features.

Video player improvements

We’ve added additional video formats, so videos should now be working on most devices. This post includes some details on how the HTML <video> tag supports multiple formats and how we generate DASH and HLS encoded versions of our videos.

Videos from Haskell Summer School

Haskell Summer School has wrapped up, and we are back to work. Recordings of our classes are available.

ZuriHac and Monadic Party

Julie just taught the beginner Haskell track at ZuriHac, and this week we are both teaching classes at Haskell Summer School in Poznań, Poland.

[Announcement] Prepare for launch

We are in the final stages of editing the initial course and project, and that content is starting to go live.

[Explainer] Function pipeline monoid

“A monoid is a pipeline of functions”? Be careful not to get lost in a particular example for a typeclass.

[Announcement] What to Expect from Type Classes

Since our initial Type Classes announcement, we’ve been asked a number of questions about payments and planned content. Find out what’s available now, when we’ll start taking payments, and what you can expect as a subscriber.

[Announcement] Type Classes are Born

On February 24, 1988, Philip Wadler introduced the idea of type “classes” for Haskell, as a solution to the problem of overloading. Thirty years later, we present Type Classes: a series of focused video courses on Haskell, Nix, and related subjects.