You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Human Guide] Add 'Status sum vs string enum' idiomatic pattern #52
Add an idiomatic pattern to the Human Guide for status sum types over stringly-typed enums. Small but pervasive in real .res/.ts/.js code. Migration target should be obvious.
Source observation
idaptik's Main.res has MultiplayerScreenWiring.dispatchDeviceStatusChanged(deviceId, "compromised"). Stringly typed. Typo "compromied" would compile and silently mis-match. The AffineScript translation introduces a sum type:
type DeviceStatus = Compromised | Clean | Suspect | Unknown;
Now typos are compile errors and match is exhaustive. Trivial change with high return.
Where to put it
Add to the Idiomatic Patterns chapter, as a peer to Branded Identifiers.
Filed from idaptik Wave 3 pilot. See LESSONS.md and PILOT.md. Idaptik commit hyperpolymath/idaptik@aef38db.
Activity