Representing Allowed States with Types
A data type can encode distinct alternatives and require each to carry the fields meaningful for that state.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 2
- Reading time
- 1 min
In this article2 chapters
Trace a result design
A read result can be found with a value, absent, or failed with a reason. Keeping all cases as one status plus arbitrary optional fields can permit inconsistent combinations. See structured errors and results.
Require case handling
Some type systems can verify that known alternatives are handled. The intended postconditions still guide each branch. Algebraic data types describe sums and products behind this representation.[1]