Skip to content

Haskell Tutorials — Complete Beginner to Advanced Guide

In this tutorial series, you'll learn Haskell from the ground up. Haskell is a purely Functional Programming language with lazy evaluation, a strong static type system, and monadic effect handling -- representing the most rigorous approach to software correctness.

1. What is Haskell?
History, purity, lazy evaluation
2. GHC Setup
Install, GHCi, Cabal, Stack
3. Pure Functions
Referential transparency, signatures
4. Types
Algebraic types, type inference
5. Pattern Matching
Cases, guards, destructuring
6. Lists
Construction, functions, comprehensions
7. Recursion
Base case, recursive step, tail
8. Higher-Order Functions
map, filter, fold, composition
9. Functors
fmap, Maybe, List, custom
10. Applicatives
pure, \<*\>, Lift
11. Monads
>>=, return, do notation
12. IO
IO monad, side effects, purity
13. Monad Transformers
MaybeT, StateT, ReaderT, WriterT
14. Cabal & Stack
Build tools, dependencies, projects
15. Type Classes
Eq, Ord, Show, custom instances
16. Foldable
foldr, foldl, foldMap
17. Zippers
Traversal, focus, updates
18. Lazy Evaluation
Thunks, infinite lists, strict
19. Algebraic Types
Sum, product, recursive types
20. Syntax
Layout, sections, operators
21. Guards
Bool guards, pattern guards
22. where and let
Local bindings, scoping
23. Modules
import, export, qualified
24. Import Tricks
Qualified, hiding, as
25. Error Handling
Maybe, Either, Exceptions
26. Testing
HSpec, QuickCheck, doctest
27. Profiling
Time, space, optimization
28. FFI
Foreign Function Interface
29. Web Development
Yesod, Servant, Scotty
30. Mini Projects
Word count, calculator, CSV

Let's begin with Lesson 1.

Published Topics

Haskell Guide — What is Haskell? Pure Functional Programming

Haskell is a purely functional programming language with lazy evaluation, a strong static type system, and monadic effect handling for correct-by-construction software.

✓ Live

Haskell GHC Setup Guide — Install Haskell and Run Your First Program

Haskell installation uses GHCup to manage GHC versions, Cabal for builds, and Stack for deterministic projects -- with GHCi for interactive exploration.

✓ Live

Haskell Pure Functions Guide — Referential Transparency and Function Signatures

Haskell pure functions always return the same output for the same input with no side effects, enabling referential transparency and mathematical reasoning about code.

✓ Live

Haskell Types Guide — Algebraic Data Types and Type Inference

Haskell has a strong static type system with algebraic data types (sum and product types), type inference, and parametric polymorphism for compile-time correctness.

✓ Live

Haskell Pattern Matching Guide — Destructuring Data with Patterns

Haskell pattern matching destructures data types through case expressions and function clauses, enabling concise and safe handling of algebraic data types and lists.

✓ Live

Haskell Lists Guide — List Operations, Ranges, and List Comprehensions

Haskell lists are homogeneous immutable singly-linked lists with operators like : (cons), ++ (append), !! (index), and powerful functions like map, filter, fold, and list comprehensions.

✓ Live

Haskell Recursion Guide — Recursive Functions, Tail Recursion, and Patterns

Haskell recursion is the primary loop mechanism, using direct recursion on lists and algebraic types, with tail-call optimization and accumulators for efficient computation without stack overflow.

✓ Live

Haskell Higher-Order Functions Guide — Map, Filter, Fold, and Function Composition

Haskell higher-order functions take functions as arguments or return them, with map, filter, foldl/foldr as core examples, and function composition (.) and application ($) enabling point-free style.

✓ Live

Haskell Functors Guide — fmap, (<$>), and the Functor Typeclass

Haskell Functor typeclass generalizes mapping over any context with fmap or (<$>), enabling map-like operations on Maybe, Either, lists, IO, and custom types with consistent behavior.

✓ Live

Haskell Applicatives Guide — Applicative Typeclass and Effectful Programming

Haskell Applicative extends Functor with pure and (<*>) for applying wrapped functions to wrapped values, enabling effectful computations with (<|>) for alternative and liftA2 for combining.

✓ Live

Haskell Monads Guide — Monad Typeclass, do Notation, and Common Monads

Haskell Monad typeclass adds (>>=) (bind) to Applicative for sequencing effectful computations where later effects depend on earlier results, with do notation providing imperative-style syntax.

✓ Live

Haskell IO Guide — Input/Output, File Handling, and Pure vs Impure Separation

Haskell IO type separates pure and impure code -- getLine/putStrLn for console, readFile/writeFile for files, with hGetLine/hPutStr for handle-based I/O and lazy I/O for streaming.

✓ Live

Haskell Records Guide — Record Syntax, Field Accessors, and Pattern Matching

Haskell records provide named fields in algebraic data types with automatic accessor functions, record pattern matching, record updates, and field puns for concise constructor and accessor code.

✓ Live

Haskell Typeclasses Guide — Eq, Ord, Show, Read, and Typeclass Deriving

Haskell typeclasses define shared behavior across types with Eq (==, /=), Ord (compare, <, >), Show (show), Read (read), and Num (+ , *) -- with automatic deriving for standard typeclasses.

✓ Live

Haskell Custom Types Guide — Algebraic Data Types, Newtypes, and GADTs

Haskell custom types use data for algebraic types with sum (|) and product (field) constructors, newtype for zero-cost type wrappers, and GADTs for precise type constraints on constructors.

✓ Live

Haskell Modules Guide — Module Declarations, Exports, and Import Control

Haskell modules organize code with module declarations controlling exports, import statements with qualified/hiding options, and hierarchical namespaces for large project structure and encapsulation.

✓ Live

Haskell Lazy Evaluation Guide — Thunks, Strictness, and Performance

Haskell lazy evaluation defers computation until needed using thunks, with seq and BangPatterns for forcing strict evaluation, enabling infinite data structures and separation of generation from consumption.

✓ Live

Haskell Error Handling Guide — Either, Maybe, Exceptions, and Safe Patterns

Haskell error handling uses Maybe for optional values, Either for error context, ExceptT for monadic error propagation, and Control.Exception for IO exceptions with bracket for resource management.

✓ Live

Haskell Testing Guide — HUnit, QuickCheck, and Test-Driven Development

Haskell testing combines HUnit for unit tests, QuickCheck for property-based testing, and doctest for documentation tests -- with cabal test and tasty for running test suites.

✓ Live

Haskell Parser Combinators Guide — Parsec, Attoparsec, and Megaparsec

Haskell parser combinators build parsers from smaller ones using (<|>) for alternation, many for repetition, and between for delimiters -- with Parsec for good errors, Attoparsec for speed.

✓ Live

Haskell Concurrency Guide — ForkIO, MVars, STM, and Async

Haskell concurrency uses forkIO for lightweight threads, MVars for shared state, STM (Software Transactional Memory) for composable atomic operations, and Async for managed concurrent results.

✓ Live

Haskell FFI Guide — Foreign Function Interface and C Interoperability

Haskell FFI (Foreign Function Interface) calls C functions using foreign import, handles memory with alloca/new/peek/poke, and manages lifetime with ForeignPtr and finalizers.

✓ Live

Haskell Profiling Guide — GHC Profiling, Cost Centers, and Optimization

Haskell profiling with GHC's -prof flags identifies performance bottlenecks through cost centers, allocation graphs, and heap profiles -- guiding optimization with INLINE, SPECIALIZE, and strictness.

✓ Live

Haskell Documentation Guide — Haddock Comments and Documentation Generation

Haskell Haddock generates API documentation from annotated source code with -- | for function docs, ^ for constructor fields, and module-level descriptions for comprehensive reference documentation.

✓ Live

Haskell Stack Guide — Stack Build Tool, Project Management, and Dependencies

Haskell Stack manages GHC versions, project dependencies, and builds with stack.yaml configuration -- providing reproducible builds through curated package sets (snapshots) and sandboxed environments.

✓ Live

Haskell Cabal Guide — Cabal Build System, Package Configuration, and Distribution

Haskell Cabal is the classic build system using .cabal files for package metadata, with cabal build/test/run commands, cabal sandboxes for isolation, and cabal sdist for source distribution.

✓ Live

Haskell GHCi Guide — Interactive REPL, Debugging, and Exploration

Haskell GHCi is the interactive environment for exploring types, testing functions, debugging with :break/:step/:continue, and profiling with :set +s for execution time and allocation.

✓ Live

Haskell GADTs Guide — Generalized Algebraic Data Types and Type Safety

Haskell GADTs (Generalized Algebraic Data Types) allow explicit type signatures per constructor, enabling type-safe DSLs, phantom type constraints, and eliminating invalid states through constructor-specific return types.

✓ Live

Haskell Type Families Guide — Type-Level Functions and Associated Types

Haskell type families define functions at the type level with closed families for pattern matching on types, open families for extensibility, and associated types for typeclass-dependent type mappings.

✓ Live

Haskell Template Haskell Guide — Meta-Programming and Code Generation

Haskell Template Haskell (TH) generates code at compile time using $(...) splices and [d|...|] quotations, with functions for manipulating names, types, and declarations for boilerplate reduction.

✓ Live

All 30 topics in Haskell Tutorials — Complete Beginner to Advanced Guide are published.