Skip main navigation

Get 30% off one whole year of Unlimited learning. Subscribe for just £249.99 £174.99. T&Cs apply

Dealing with Uncertainty

Sometimes computations do not generate expected results. Such functions can return Maybe values, as Jeremy Singer explains in this video.

What do we do when computations fail to generate results? Examples include taking the head of an empty list, or finding the minimum value of a tree which turns out to be a Leaf.

Haskell provides Maybe values, which allow us to denote missing results with Nothing. This is type-safe, so much better than null in C-like languages. Maybe is like Option in Scala.

This article is from the free online

Functional Programming in Haskell: Supercharge Your Coding

Created by
FutureLearn - Learning For Life