The Elm Architecture
Tyrian provides a runtime environment for executing applications that was originally designed according to the Elm architecture.
Elm is the name of a language and an ecosystem, but it's architecture has become more widely known as the 'TEA Pattern' ((T)he (E)lm (A)rchitecture) and has influenced many GUI/UI libraries and implementations beyond the world of functional programming.
The TEA pattern
The TEA Pattern is about:
- Immutable data.
- Pure functions.
- Uni-directional data flow.
- Strictly ordered events and updates.
This gives you a system that is very easy to reason about, since the data cannot (or is unlikely to) be subject to hard-to-test race conditions or side effects, and everything happens in a predictable order.
The purity of the system, the way that the state is held apart from the processing and rendering functions, also allows for easy testing without the need for complex mocking.
- The state of the application is modeled by an immutable
- Events that change the state of the application are modeled by an immutable
- State transitions are implemented by a
(Msg, Model) => Modelfunction.
- Finally, a
Model => Html[Msg]function defines how to render the state of the application in HTML.