Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/MystPi/act
🎬 Compose stateful actions to simulate mutable state
https://github.com/MystPi/act
functional-programming gleam monad state
Last synced: 3 months 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 (8 months ago)
- Default Branch: main
- Last Pushed: 2024-06-06T12:14:26.000Z (5 months ago)
- Last Synced: 2024-07-12T09:14:49.557Z (4 months ago)
- Topics: functional-programming, gleam, monad, state
- Language: Gleam
- Homepage: https://hexdocs.pm/act
- Size: 19.5 KB
- Stars: 13
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-gleam - act - [📚](https://hexdocs.pm/act/) - Compose stateful actions to simulate mutable state (Packages / Data Structures)
README
# 🎬 act
[![Package Version](https://img.shields.io/hexpm/v/act)](https://hex.pm/packages/act)
[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](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
```