sum types: delete the impossible combinations
pain: a struct with optional fields allows nonsense.
that gives 2 × 2 × 2 = 8 shapes, and only 3 of them mean anything.
=> list only the real cases:
origin: the Hope and ML languages, late 1970s. Yaron Minsky later gave the goal its slogan: "make illegal states unrepresentable".
rust
struct Conn { socket: Option<Socket>, retry: Option<u8>, error: Option<String>, }
rust
enum Conn { Retrying(u8), Open(Socket), Failed(String), }
commit 974d44c