Chapter C1
The language, in depth
F# taught on its own terms — not a curiosity beside C#, but a complete way to build software.
This is the spine of the course. Nine modules take F# from its smallest parts to its most expressive: values and types, let bindings, functions, the pipe and composition, pattern matching, discriminated unions and records, the collections, Option and Result, and finally computation expressions. Every snippet is valid, idiomatic F# you can paste into F# Interactive and run. Read them in order — each module leans on the one before it.
How to read this chapter
F# is functional-first: functions and immutable values are the default tools, and the type system works for you rather than against you. The chapter is built so each module leans on the one before it. Values and their types come first, because everything else is made from them. Bindings name those values. Functions transform them. The pipe and composition wire functions together. Pattern matching, unions, and records shape the data; Option and Result turn absence and failure into ordinary values; computation expressions tie the threads into a small language of your own.
One habit to start with: read the types. F# infers a type for every expression, and F#
Interactive — the REPL, started with dotnet fsi — echoes it back. Select an
expression below to see what FSI prints: the value, and the type it inferred.
F# Interactive · evaluate an expression
// you type 1 + 2 * 3;; // FSI prints val it : int = 7
If you can read the type FSI prints, you can read most F#. The type is the contract; the value is one inhabitant of it.
The nine modules
The chapter in order, the final module a hands-on lab. Each module carries three dives, and each leans on the one before it — values, then names, then functions, then how they compose and combine.
Values, types & FSI
The data you build with; F# Interactive as a tool to explore it.
let bindings, immutability & shadowing
A name binds a value; rebinding shadows, it does not mutate.
Functions, currying & partial application
Every function takes one argument; the rest is currying.
The pipe |> and composition >>
Threading values and gluing functions, left to right.
Pattern matching & active patterns
Branch by structure; extend matching with your own patterns.
Discriminated unions & records
Sum and product types; making illegal states unrepresentable.
Collections — list, array, seq, Map & Set
The core containers and when to reach for each.
Option, Result & railway-oriented errors
No nulls, no exceptions for control flow — errors in the type.
Computation expressions & async
A lab: build a small computation expression and run async work.
References
Sources
- Microsoft — F# documentation — the language guide, the tour of F#, and the reference.
- The F# language specification — the precise rules for values, types, bindings, and functions.
- FSharp.Core API reference — the core library: List, Option, the operators.
- The F# Software Foundation — the language's home and community.
Related in this course
- F# In Depth — course home — the full C0–C5 map.
- C0 · History — where the language and its ideas come from.
- Elixir · Functional Programming — the same ideas on the BEAM, for contrast.