Skip to content
Tutorials Center
My learning

Topics

Haskell Tutorial

Learn Haskell step by step: 57 lessons in 11 chapters with examples, quizzes, diagrams and projects.

Start learning →

of lessons completed

Getting started

  1. 1 Introduction to Haskell Meet Haskell, a purely functional language with static types and lazy evaluation. See what makes it different, where it is used, and how this course runs code.
  2. 2 Installing GHC and Using GHCi Install the Haskell toolchain with GHCup, then learn the GHCi commands :t, :i, :r and :l, how to use runghc, and what Cabal and Stack are for.
  3. 3 Your First Haskell Program Write and compile a Haskell program: main, putStrLn, do blocks, the module header, comments and the layout rule that uses indentation instead of braces.
  4. 4 Expressions, Functions and Application Learn how Haskell treats everything as an expression, how to call and define functions without parentheses, use infix operators and write operator sections.

Types and values

  1. 5 Basic Types and Type Signatures Learn Haskell's basic types Int, Integer, Double, Bool, Char and String, how to read type signatures like a -> b -> c, and how type inference fills gaps.
  2. 6 Type Classes: Eq, Ord, Show, Read, Num Understand Haskell type classes and constraints like Eq a =>, learn Eq, Ord, Show, Read and Num, use deriving, and see how numeric defaulting works.
  3. 7 Tuples and Lists Learn Haskell tuples and lists: fixed-size tuples with fst and snd, list literals, the cons operator, ranges, and head, tail, take and drop.
  4. 8 List Comprehensions Build Haskell lists the way mathematicians write sets: generators, guards, nested generators, let bindings and pattern filters, with examples.
  5. 9 Strings, Chars and Text Understand Haskell String as a list of Char, use Data.Char, show and read, words and lines, and learn when to reach for Data.Text instead.

Functions

  1. 10 Pattern Matching Learn Haskell pattern matching: literals, tuples, lists, wildcards, as-patterns, case expressions and what happens with non-exhaustive patterns.
  2. 11 Guards, where and let Write conditions with Haskell guards and if-then-else, then name intermediate values with where and let. Includes otherwise and MultiWayIf.
  3. 12 Recursion Learn recursion in Haskell: base and recursive cases, accumulators, tail recursion, and how laziness and strictness affect stack and memory use.
  4. 13 Currying and Partial Application Learn why every Haskell function takes one argument, how partial application and operator sections work, and when point-free style helps or hurts.
  5. 14 Higher-Order Functions: map, filter, folds Learn Haskell higher-order functions: map, filter, foldr, foldl, foldl', zip, zipWith and iterate, with clear examples and runnable JavaScript stand-ins.
  6. 15 Lambdas, Composition and the $ Operator Learn Haskell lambda syntax, the composition operator (.), the application operator ($), flip and how to build readable function pipelines.

Defining types

  1. 16 Algebraic Data Types Learn how to define your own Haskell types with data: constructors, sum and product types, records, deriving and pattern matching on constructors.
  2. 17 Records, newtype and Type Synonyms Learn Haskell record syntax and updates, field accessors, the difference between newtype, data and type, and when to use strict fields.
  3. 18 Maybe and Either Learn how Haskell models missing values with Maybe and failures with Either, using fromMaybe, maybe, either, chaining and total functions.
  4. 19 Recursive Data Types and Trees Learn how Haskell types can refer to themselves: build lists, binary search trees and expression trees, then evaluate and fold over them.
  5. 20 Parametric Polymorphism and Type Variables Understand Haskell type variables, parametric polymorphism, what a signature like a -> a can and cannot do, and how class constraints narrow it.
  6. 21 Defining Your Own Type Classes and Instances Learn to declare a Haskell type class, write instances, use default methods and deriving, and avoid orphan instances, with a runnable JavaScript stand-in.

Laziness and purity

  1. 22 Lazy Evaluation Learn how Haskell delays work until a value is needed: thunks, call by need, infinite lists with take, iterate and cycle, and when laziness helps.
  2. 23 Strictness, Bang Patterns and seq Learn why lazy accumulators leak memory in Haskell and how foldl', seq, bang patterns, strict fields and deepseq force evaluation at the right time.
  3. 24 Purity and Referential Transparency Understand pure functions, referential transparency and equational reasoning in Haskell, and why purity makes code easier to test, refactor and optimise.

Functors, applicatives and monads

  1. 25 Functors Understand the Haskell Functor class: how fmap and <$> apply a function inside Maybe, lists and functions, and which laws every instance must obey.
  2. 26 Applicative Functors Learn Haskell's Applicative class: pure, <*>, liftA2 and applicative style for combining independent wrapped values, such as validating form fields.
  3. 27 Monads A clear, myth-free introduction to Haskell monads: the >>= operator, Maybe and list monads, the three monad laws, and a runnable JavaScript stand-in.
  4. 28 do-Notation Demystified See how Haskell do blocks desugar into >>= and >>, how let and pattern matching work inside do, and why do is not just for IO.
  5. 29 Semigroups and Monoids Learn Haskell's Semigroup and Monoid classes: combining values with <>, identity elements, Sum, Product, Any, All, mconcat and foldMap, with examples.
  6. 30 Foldable and Traversable Learn Haskell's Foldable and Traversable classes: fold any container, then use traverse, sequenceA and mapM to run effects such as validation over a list.
  7. 31 State, Reader, Writer and Monad Transformers Learn the State, Reader and Writer monads, then stack effects with StateT and ExceptT and the mtl style. Includes a runnable State stand-in.

IO and the real world

  1. 32 IO Basics Learn how Haskell handles input and output: the IO type, getLine, putStrLn, return versus pure, sequencing, interact and why IO actions are values.
  2. 33 Files, Arguments and Environment Read and write files in Haskell with readFile, writeFile and withFile, handle getArgs and exit codes, and avoid the lazy IO trap.
  3. 34 Exceptions and Error Handling Handle failure in Haskell: choose between Maybe, Either and exceptions, use throwIO, catch, try, bracket and ExceptT, and define custom exceptions.
  4. 35 Mutable State: IORef, MVar and ST Learn when and how to use mutable variables in Haskell: IORef and modifyIORef', MVar for sharing, and the ST monad with STRef and STUArray.

Modules, packages and tooling

  1. 36 Modules and Imports Organize Haskell code with modules: the module header, export lists, qualified imports, hiding Prelude names and fixing ambiguous name clashes.
  2. 37 Cabal, Stack and Packages Create a Haskell project with Cabal or Stack, read a .cabal file, add dependencies from Hackage and Stackage, and learn the standard project layout.
  3. 38 Essential Libraries: containers, text, bytestring, vector Meet the Haskell libraries almost every project uses: Data.Map and Data.Set, Data.Sequence, Text, ByteString and Vector, and learn how to pick the right one.
  4. 39 Testing: HUnit, Hspec and QuickCheck Test Haskell code with HUnit and Hspec for examples and QuickCheck for properties, and learn how generators, shrinking and doctest fit together.
  5. 40 Debugging, Profiling and Performance Find bugs and slow code in Haskell: Debug.Trace, GHC warnings with -Wall, HLint, GHCi breakpoints, profiling, strictness, list fusion and criterion benchmarks.

Advanced types

  1. 41 GHC Extensions Worth Knowing Learn what LANGUAGE pragmas do and which GHC extensions are worth knowing: LambdaCase, TupleSections, RecordWildCards, OverloadedStrings and TypeApplications.
  2. 42 GADTs, Type Families and DataKinds Use GADTs for a type-safe expression evaluator, type families to compute types, and DataKinds with phantom types to make illegal states unrepresentable.
  3. 43 Lenses and Optics Learn what Haskell lenses are: getters and setters as composable values, view, over and set, the lens and optics libraries, plus a runnable JavaScript stand-in.
  4. 44 Effect Systems and Free Monads Understand how Haskell separates what a program does from how it runs: tagless final, free monads, and effect libraries, with a runnable JavaScript stand-in.
  5. 45 Concurrency and Software Transactional Memory Learn Haskell concurrency: lightweight threads with forkIO, MVar as a lock and channel, STM and TVar for safe shared state, async, and parallelism with par.

Real-world Haskell

  1. 46 Parsing with Parser Combinators Build a Haskell parser from small functions: Parser as a function, Functor, Applicative and Alternative instances, an expression grammar, and megaparsec.
  2. 47 JSON and Web Services Encode and decode JSON in Haskell with aeson and generics, then see how Scotty and servant build web services and how wreq calls other APIs.
  3. 48 Project: Expression Calculator Build an arithmetic calculator in Haskell in three stages: a tokenizer, a parser into an expression tree, and an evaluator with Either errors, plus tests.
  4. 49 Project: Command-Line Todo App Build a todo manager in Haskell: records, a pure core, file persistence, optparse-applicative commands and Hspec tests, with a runnable JS model.
  5. 50 Project: Bank Account Simulator with State Build a bank account simulator in Haskell with Either errors, the State monad and transaction replay, plus a runnable JavaScript model.
  6. 51 Project: JSON Parser from Scratch Build a JSON parser and pretty printer in Haskell with a small parser-combinator library, then test a round trip. Includes runnable JS models.
  7. 52 Project: Text Adventure Engine Build a text adventure in Haskell: the world as data, a command parser, a pure step function and a thin IO loop, with a runnable JavaScript model.

Practice and interviews

  1. 53 Practice: Functions, Lists and Recursion Fifteen Haskell exercises with solutions on map, filter, folds, recursion and lazy lists, plus runnable JavaScript checks to test your ideas.
  2. 54 Practice: Types, Classes and Monads Twelve Haskell exercises with solutions on algebraic data types, Maybe and Either, type classes, folds and monad chaining, with runnable JS checks.
  3. 55 Common Mistakes and Error Messages Learn the Haskell mistakes beginners hit most: type errors, layout problems, ambiguous types, partial functions and space leaks, and how to read GHC messages.
  4. 56 Haskell Interview Questions Prepare for Haskell interviews with short, accurate answers on laziness, purity, type classes, monads, folds, GHC and tooling, plus runnable stand-ins.
  5. 57 Haskell Cheat Sheet A compact Haskell cheat sheet: syntax, Prelude functions, type classes, monad idioms, GHCi commands and common GHC extensions, with links to each lesson.