Make invalid states representable.
We should model the state of a system using algebraic types and include states that are invalid.
A favorite functional programming motto is “make invalid states representable.” If we can fully model the possible states of a system using algebraic types—including states that are invalid—then we can provide good error messages that describe why something is invalid, and we have more possibilities for recovering from error.
A datatype: Configuration
Keep reading with a 7-day free trial
Subscribe to Type Classes to keep reading this post and get 7 days of free access to the full post archives.