Haskell
Overview
Haskell is a pure functional language with lazy evaluation, strong static typing, and type classes. It encourages reasoning via equational laws and composition (map, folds, monads) and influences many mainstream languages’ type systems.
Key concepts
- Purity — Functions without hidden side effects by default.
- Lazy evaluation — Compute values on demand (with space pitfalls).
- Algebraic data types —
data+ pattern matching. - Type classes — Ad-hoc polymorphism (
Eq,Functor,Monad). - Monads — Structured effects (
IO,Maybe,Either).
Evaluation model (simplified)
Sample: types and functions
data Shape = Circle Double | Rect Double Double
area :: Shape -> Double
area (Circle r) = pi * r * r
area (Rect w h) = w * h