λ

HASKELL

A field guide to functional programming

λ
Type
Maybe a
Either e a
[a]
Nothing
Just a
Left e
Right a

Specimen I · Type ecology

Types are the skeleton beneath the leaves

Haskell's type system describes the shape of a program before the program ever runs. It is not a cage; it is the botanical diagram pinned beside the specimen, showing which branches can grow and which impossible mutations are rejected.

A value may be present, absent, successful, failed, singular, recursive, finite, or infinite. Types make those states explicit, searchable, and hard to accidentally ignore.

safeHead :: [a] -> Maybe a
λ
raw data
map
filter
fold

Specimen II · Composition

Functions grow by grafting

Pure functions are small, predictable organisms. Feed them the same input and they produce the same fruit. Composition lets those organisms interlock into pipelines where data travels through transformation after transformation without hidden state clinging to it.

The result is code that reads like a field note: observe, transform, classify, reduce. Every step can be lifted out and examined under glass.

result = foldr (+) 0 . filter even . map (*2)
λ
IO String
>>=
String -> IO Name
>>=
Name -> IO Greeting
>>
putStrLn greeting

Specimen III · Controlled impurity

Monads are greenhouse glass

Effects are not banished from Haskell; they are cultivated in labeled enclosures. A monad describes a context for sequencing computations: input, output, state, failure, possibility, nondeterminism.

The bind operator threads each result into the next step while preserving the walls of the enclosure. Impurity becomes visible, typed, and composable.

(>>=) :: m a -> (a -> m b) -> m b
λ
pure
referential
lazy
immutable
composable

Specimen IV · Purity

No hidden roots under the soil

Purity means an expression can be replaced by its value without changing the behavior of the program. There are no secret tendrils reaching into global state, no mutation flowering behind your back.

That constraint is not austerity. It is a growing condition. Under it, equational reasoning blooms, tests become simpler, and large programs become less haunted.

area r = pi * r * r