Subscribe for updates and more.

Make illegal states unrepresentable

Planted 02024-07-24

Firstly, No silver bullet.

  1. State functions
  2. Type system

State functions

FSM: State and transition explosion

A finite-state machine (FSM) or finite-state automaton (FSA, plural: automata), finite automaton, or simply a state machine, is a mathematical model of computation. It is an abstract machine that can be in exactly one of a finite number of states at any given time. The FSM can change from one state to another in response to some inputs; the change from one state to another is called a transition. An FSM is defined by a list of its states, its initial state, and the inputs that trigger each transition. Finite-state machines are of two types—deterministic finite-state machines and non-deterministic finite-state machines. For any non-deterministic finite-state machine, an equivalent deterministic one can be constructed.

Wikipedia: Finite-state machine

The complexity of a traditional FSM tends to grow much faster than the complexity of the system it describes.

Hierarchically nested states

Statecharts, UML state diagrams, hierarchical state machines (HSMs)

Local vs global vs server

UI is a function of your remote state and your local state

Data Flow in Remix

References

Type system

Discriminated unions

Testing types in TypeScript

References