Thinking about Haskell?
Whether you're just beginning, or ready to put principles into practice, we're your guide.

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


Courses

Courses are series about a particular topic meant to be watched in order. Some are more theory-and-fundamentals oriented, while some focus on building a project. Each course has clearly identified prerequisites and goals, to help you choose which courses are right for you.

Web Servers, at a low level
6 videos; 49 minutes
This course starts by discussing what HTTP and web servers are and follows the HTTP specification in building a Haskell web server from scratch. This includes explaining different character encodings and the differences between the Haskell Text and ByteString types.
Functortown
This course will be a complete survey of functors, addressing such issues as what functors are in general and how the different functors are related to each other. It will be a long course, spending 3-5 lessons on each typeclass, and cover Functor, Bifunctor, Applicative, Traversable, Monad, Contravariant, and Profunctor, with motivating examples and discussions of what each is good for, the laws governing each, and how to property test instances.
Timepieces
Explore native GUI programming in Haskell! This course is all about making native clock applications. We’re starting off the course by alternating between Julie using fltkhs and Chris using gtk3. Each lesson explains aspects of the library, illuminates important Haskell concepts such as concurrency primitives and implicit parameters, and gives you some basis for comparing libraries for your own native GUI application projects.
The Validation Course
9 videos; 150 minutes
Starting from basic conditional statements and pattern matching, we build a suite of functions to validate user inputs, refactoring along the way to see what benefits using Maybe, Either, and Validation types brings, as well as using newtype to differentiate inputs. We also demonstrate the difference between Applicative and Monad.
NixOS on AWS
5 videos; 36 minutes
Writing a script with Turtle to launch/update an EC2 instance

Reference

Each article explains a single, sometimes small, Haskell topic in detail. Some articles include video. Haskell reference pages supplement, but are independent of, the courses and projects. Haskellers of any level will find them useful as reference.

Transformers and deriving
We walk through a common use case for ReaderT from the transformers library and use it to illustrate type aliases, newtypes, and various approaches for typeclass deriving, using the GeneralizedNewtypeDeriving and DerivingVia GHC extensions.
Thread concepts
Concurrency is a great strength of Haskell’s, in part thanks to the runtime system which provides lightweight threads. You can also create OS threads (called “bound” threads), which is sometimes needed for FFI.
Primitives, levity, and boxing
GHC makes it possible to access a lot of internals that most programming languages would hide away entirely. Rarely do you need them, but we get curious when we hear people talk about primitive, lifted, and boxed types.
Compile-time evaluation
A straightforward common application of the often-daunting Template Haskell: How to make constant expressions evaluate during compilation to avoid one source of runtime errors.
Understanding contravariance
23-minute video
Contravariant functors can seem difficult to approach, but in this article, we look at them as a variation on a familiar theme: function composition.
Understanding profunctors
Once you’ve understood contravariant functors, you are so ready for profunctors! Profunctors extend and generalize the concept of a functor, but under the hood, they’re still made of function composition.
Introduction to GHC language extensions
GHC Haskell has a lot of language extensions, ranging from very simple syntactic extensions to very complex type drama. This article helps you understand what extensions are, how to use them, and which ones are especially useful as your first extensions.
Type applications
7-minute video
One of the first language extensions we recommend for Haskell learners and one we use often while teaching, TypeApplications lets you visibly apply functions to type arguments. We demonstrate several common use cases.
Scoped type variables
9-minute video
Another useful language extension that we recommend for learners and pros alike, ScopedTypeVariables lets you extend the scope of a type variable over a whole function, including its subexpressions.
Overloaded strings
13-minute video
You will certainly run into this language extension often. This opinionated piece explains what it is and why it’s so common as well as when you might not want to use it.
Monomorphism restriction
Sometimes your functions aren’t as polymorphic as you thought they were. This article helps you understand why the monomorphism restriction exists and how to work with it.

Transitions

Switching to Haskell doesn’t mean you have to start over learning how to code. Our transitions content is geared toward explaining how concepts from other languages relate to Haskell, so you can advantage of what you already know as you get started in Haskell. We focus on Java, JavaScript, and Python.

Operators in JavaScript and Haskell
8-minute video
Transfer your knowledge of JS operator tricks into Haskell
A JavaScript WAT and monoidal folds
We examine a puzzling fact about Math.max() < Math.min() and what it has to do with monoids. This is a two-part article covering Haskell’s folds (compared to JavaScript reduce), monoids, and identity values.
Function decorators in Python
If you like Python decorators, you’ll love higher-order functions. Here we show a direct comparison between decorators in the Flask framework and higher-order functions in scotty, a Haskell web framework.

Tooling

This section covers topics that aren’t about the Haskell language itself, but about software that helps you be more productive with it.

Viewing type information in GHCi
Master the :type command and never be at a loss for knowledge of types
Typed holes
Get the compiler to help you develop code incrementally
GHCi configuration
Customize your Haskell REPL
Using ghcid
A simple but incredibly convenient tool that shows compile output in real-time as you edit.