Gleam is a functional programming language that does not support having mutable state. As such, programmers often have to pass state around manually, threading it through functions via arguments and return values. This can become a bit repetitive and clumsy.
What if state could be 'threaded' through functions automatically, with a nice API that resembles mutable state? This is the central idea of act
and the Action
type.
type Action(result, state) = fn(state) -> #(state, result)
act
is inspired by the (now outdated) gleam-eval package.gleam-eval
is super cool, but only supports theResult
type and was not created with Gleam'suse
feature in mind.
gleam add act
Documentation can be found at https://hexdocs.pm/act. A simple example lives in test/act_test.gleam.
gleam run # Run the project
gleam test # Run the tests