Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/RedPRL/algaeff
🦠Reusable components based on algebraic effects
https://github.com/RedPRL/algaeff
algebraic-effects ocaml ocaml-library
Last synced: about 1 month ago
JSON representation
🦠Reusable components based on algebraic effects
- Host: GitHub
- URL: https://github.com/RedPRL/algaeff
- Owner: RedPRL
- License: apache-2.0
- Created: 2022-03-30T20:16:48.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-02-23T17:03:09.000Z (10 months ago)
- Last Synced: 2024-05-31T11:38:39.864Z (7 months ago)
- Topics: algebraic-effects, ocaml, ocaml-library
- Language: OCaml
- Homepage:
- Size: 690 KB
- Stars: 44
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.markdown
- Changelog: CHANGELOG.markdown
- Contributing: CONTRIBUTING.markdown
- License: LICENSE
Awesome Lists containing this project
README
# 🦠Reusable Effects-Based Components
This library aims to collect reusable, general effects-based components we have seen when constructing our proof assistants using OCaml 5. All components here have appeared in various tutorials on algebraic effects; `algaeff` wraps these well-known components into an OPAM package.
## API Stability
We use [semantic versioning.](https://semver.org/) Breaking changes will bump the major version number.
## Components
- [Algaeff.State](https://redprl.org/algaeff/algaeff/Algaeff/State): mutable states
- [Algaeff.Reader](https://redprl.org/algaeff/algaeff/Algaeff/Reader): read-only environments
- [Algaeff.Sequencer](https://redprl.org/algaeff/algaeff/Algaeff/Sequencer): making a `Seq.t`
- [Algaeff.Mutex](https://redprl.org/algaeff/algaeff/Algaeff/Mutex): simple locking to prevent re-entrance
- [Algaeff.UniqueID](https://redprl.org/algaeff/algaeff/Algaeff/UniqueID): generating unique IDsEffects-based concurrency (cooperative lightweight threading) was already tackled by other libraries such as [Eio](https://github.com/ocaml-multicore/eio) and [Affect](https://erratique.ch/software/affect). This library focuses on the rest.
There are a few other useful functions:
- [Algaeff.Fun.Deep.finally](https://redprl.org/algaeff/algaeff/Algaeff/Fun/Deep/index.html#val-finally): call `continue` or `discontinue` accordingly.
- [Algaeff.Fun.Shallow.finally_with](https://redprl.org/algaeff/algaeff/Algaeff/Fun/Shallow/index.html#val-finally_with): same as above, but for shallow effect handlers.## How to Use It
### OCaml >= 5.0.0
You need OCaml 5.
### Example Code
```ocaml
module S = Algaeff.State.Make (Int)let forty_two = S.run ~init:100 @@ fun () ->
print_int (S.get ()); (* this will print out 100 *)
S.set 42;
S.get ()
```### Documentation
[Here is the API documentation.](https://redprl.org/algaeff/algaeff/Algaeff)