A data type defines the values that may exist in a domain and the constructors used to build them. Domain types therefore act as a small embedded domain-specific language: business concepts become explicit code rather than scattered primitives. section 5.1.1
A type also gives the compiler a design boundary. When functions declare and consume precise types, invalid combinations can fail during compilation instead of becoming debugging problems at runtime. section 1.5.2
Representing shapes
Shape makes the alternatives explicit: Circle carries a radius, while Rectangle carries width and height. The area function pattern-matches on those constructors, so its cases correspond directly to the type’s possible values. Calling area with an integer fails because the function requires Shape. section 1.5.2
data Shape = Circle Double
| Rectangle Double Double
Inspect the type declaration that defines Shape and its constructors. section 1.5.2
area :: Shape -> Double area (Circle r) = pi * r^2 area (Rectangle w h) = w * h
Inspect the function whose pattern-matching cases consume the Shape values. section 1.5.2
















