Static typing moves important correctness checks into program design: an expressive type system and compiler can reject invalid constructions before execution, reducing reliance on step-by-step debugging. section 1.5.2
The technique becomes especially valuable when types describe domain rules. Algebraic data types and pattern matching can make valid cases explicit, while the compiler catches calls that do not match the declared model. section 1.5.2 section 5.1
Static typing supports several design goals:
- Catch classes of errors before running the program, including passing an integer where a Shape is required. section 1.5.2
- Make domain operations safer by restricting programs to correct states and permitted operations. section 5.1
- Support functional design alongside purity, algebraic data types, type classes, and higher-kinded types. section 1.5.1 section 5.1
A typed shape function
Define Shape with Circle and Rectangle constructors, then declare area :: Shape -> Double. Calling area with 5 produces a compiler error because Integer does not match Shape. The type declaration and pattern matches expose the intended domain cases directly. section 1.5.2
data Shape = Circle Double
| Rectangle Double Double
Browse the Shape algebraic data type, its area function, an invalid call, and the resulting compiler diagnostic. section 1.5.2











