https://github.com/mystpi/act
🎬 Compose stateful actions to simulate mutable state
https://github.com/mystpi/act
functional-programming gleam monad state
Last synced: 17 days ago
JSON representation
🎬 Compose stateful actions to simulate mutable state
- Host: GitHub
- URL: https://github.com/mystpi/act
- Owner: MystPi
- License: apache-2.0
- Created: 2024-03-24T18:54:31.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-12-01T19:53:58.000Z (4 months ago)
- Last Synced: 2026-02-26T17:14:25.867Z (23 days ago)
- Topics: functional-programming, gleam, monad, state
- Language: Gleam
- Homepage: https://hexdocs.pm/act
- Size: 21.5 KB
- Stars: 27
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# 🎬 act
[](https://hex.pm/packages/act)
[](https://hexdocs.pm/act/)
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`](https://hexdocs.pm/act/act.html#Action) type.
```gleam
type Action(result, state) = fn(state) -> #(state, result)
```
> `act` is inspired by the (now outdated) [gleam-eval](https://github.com/hayleigh-dot-dev/gleam-eval) package. `gleam-eval` is super cool, but only supports the `Result` type and was not created with Gleam's `use` feature in mind.
## Installation
```sh
gleam add act
```
## Docs & Example
Documentation can be found at . A simple example lives in [test/act_test.gleam](https://github.com/MystPi/act/blob/main/test/act_test.gleam).
## Development
```sh
gleam run # Run the project
gleam test # Run the tests
```