Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/s5bug/cxxeffect
An "experiment" to create functional streams in C++
https://github.com/s5bug/cxxeffect
Last synced: 2 months ago
JSON representation
An "experiment" to create functional streams in C++
- Host: GitHub
- URL: https://github.com/s5bug/cxxeffect
- Owner: s5bug
- License: mit
- Created: 2021-04-30T07:15:56.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-07-18T23:20:35.000Z (over 2 years ago)
- Last Synced: 2024-03-15T08:22:28.990Z (11 months ago)
- Language: C++
- Size: 79.1 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# cxxeffect
## api goals
| type | explanation |
|---------------|--|
| `⊥` | bottom/empty/never type. cannot be created lawfully |
| `⊤` | top/unit/void type. all instances are equal to `eff::top()` |
| `α + β` | either `α` or `β` |
| `α × β` | both `α` and `β` |
| `callback<α>` | `(exception + α) → ⊤`, a callback that accepts a failure or success |
| `outcome<α>` | `⊤ + exception + α`, either cancelled (`⊤`), errored, or completed |
| `poll` | a polymorphic `(A : Type) → task → task` |### `task`
Represents a program with a specific result type.
| function | type |
|----------------|------------------------------------------------------------------|
| `async` | `(callback<α> → task>>) → task<α>` |
| `async_` | `(callback<α> → ⊤) → task<α>` |
| `blocking` | `(⊤ → α) → task<α>` |
| `bracket` | `task<α> → (α → task<β>) → (α → outcome<β> → task<⊤>) → task<β>` |
| `canceled` | `task<⊤>` |
| `delay` | `(⊤ → α) → task<α>` |
| `never` | `task<⊥>` |
| `pure` | `α → task<α>` |
| `race` | `task<α> → task<β> → task<(α × fiber<β>) + (fiber<α> × β)>` |
| `uncancelable` | `(poll → task<α>) → task<α>` |
| `as` | `task<α> → β → task<β>` |
| `flatMap` | `task<α> → (α → task<β>) → task<β>` |
| `map` | `task<α> → (α → β) → task<β>` |
| `start` | `task<α> → task>` |### `fiber`
Represents an in-progress computation.
| function | type |
|----------|--------------------|
| `cancel` | `task<⊤>` |
| `join` | `task>` |### `resource`
Represents a resource that can be acquired and released.
| function | type |
|-----------|-------------------------------------------------|
| `flatMap` | `resource<α> → (α → resource<β>) → resource<β>` |
| `map` | `resource<α> → (α → β) → resource<β>` |
| `use` | `resource<α> → (α → task<β>) → task<β>` |### `dispatcher`
A way to run pure code / tasks in impure / synchronous environments.
| function | type |
|-----------------------------|--------------------------------------------------------|
| `make_dispatcher` | `resource` |
| `unsafeToFutureCancellable` | `dispatcher → task<α> → (future<α> × (⊤ → future<α>))` |
| `unsafeToFuture` | `dispatcher → task<α> → future<α>` |
| `unsafeRunAndForget` | `dispatcher → task<α> → ⊤` |