Mathematical background: Lambda Calculus — abstraction, β-reduction, and the Church-Turing thesis
A function f :: a ⟶ b takes a value of type a (the domain) and produces a value of type b
(the codomain).
A pure function has no side effects — its result depends solely on its arguments. You could memoize it. It is easy to test and reason about.
An impure function may read/write files, access global state, call non-deterministic operations (time, RNG), or throw exceptions. These effects are not visible in the type signature.
A total function produces a result for every value in the domain.
A partial function is undefined on some inputs (e.g. division by zero, head of an empty list).
- Declaration:
f :: a ⟶ b—fmaps any value of typeato a value of typeb. - Application:
f(a0) = b0— applyingfto a specific valuea0 :: ayieldsb0 :: b.