← Back to context

Comment by 4ad

2 years ago

> it was too late to make invalid states unrepresentable

It wasn't, that's exactly what you did, albeit not with types, but by removing redundancies from the state. It's the same reason why normalizing relational databases is a good idea.

> It wasn't, that's exactly what you did

the thing with using types to make unrepresentable state is that it ensures the compiler is the one checking.

By doing it "manually" this way, you're not saving much effort. You still had to make the analysis of which state is valid, and to code it up (hopefully without a mistake). The state of the program can also temporarily be invalid - just happens to fast for the user to notice (thus "fixing" the bug).

It's probably the best that could've been done other than a rewrite, but make no mistake - it's not the ideal.