Reading Note: The Elm Architecture

2022-03-28softwarefunctionalelmfrontend

One of the things I love about Elm is its architecture. It is simple and powerful. The Elm Architecture gives you a solid way for handling the state of your application.

The basic structure of an Elm application looks like this:

elm-architecture

Model

I already have a blog post related to Elm Model in this post Model and Record in Elm

In short, model contains all of your application states. Typically, a model is a record data type.

View

Update

All states are located in the model, all changes to the model have to take place in the update function.

The update function takes two arguments:

The update function is responsible for interpreting the message to change the state. The data types in Elm are immutable. So, the update function must return a new instance of the model with the changed state.

Runtime

I wrote a post related to Virtual DOM in Elm. This post mentions the model, view, update, and runtime interaction.

Some personal thoughts

There are a lot of reasons to love Elm Architecture. For me:

One of my big dislikes is that I am hard to integrate other UI stuff into my application. Maybe I will have a more detailed post related to this issue later.

References