Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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++

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<α> → ⊤` |