| Crates.io | effect-rs |
| lib.rs | effect-rs |
| version | 0.1.0 |
| created_at | 2026-01-10 05:06:33.119082+00 |
| updated_at | 2026-01-10 05:06:33.119082+00 |
| description | A high-performance, strictly-typed, functional effect system for Rust. |
| homepage | https://github.com/copyleftdev/effect-rs |
| repository | https://github.com/copyleftdev/effect-rs |
| max_upload_size | |
| id | 2033462 |
| size | 157,235 |
A high-performance, strictly-typed, functional effect system for Rust.
⚠️ Note: This project is currently in active development / alpha stage.
Effect-rs brings the power of functional effect systems (inspired by ZIO, Cats Effect) to the Rust ecosystem. It provides a robust framework for building asynchronous, concurrent, and resilient applications with ease.
R, may fail with E, or succeed with A.Effect type.Schedule and Retry policies to handle failures gracefully.TestRuntime and TestClock for reliable, time-dependent testing.Add this to your Cargo.toml:
[dependencies]
effect-rs = "0.1.0"
tokio = { version = "1", features = ["full"] }
use effect_rs::{Effect, Runtime};
fn main() {
let program = Effect::succeed("Hello, World!")
.map(|msg| println!("{}", msg));
Runtime::new().block_on(program, ());
}
use effect_rs::{Effect, Runtime, EnvRef};
use std::sync::Arc;
struct Config {
app_name: String,
}
fn print_config() -> Effect<Arc<Config>, (), ()> {
Effect::access_async(|env: EnvRef<Arc<Config>>, _| async move {
println!("Running app: {}", env.value.app_name);
})
}
fn main() {
let config = Arc::new(Config { app_name: "MyEffectApp".into() });
let rt = Runtime::new();
rt.block_on(print_config(), config);
}
use effect_rs::{Effect, Runtime};
use std::time::Duration;
fn main() {
let rt = Runtime::new();
let program = Effect::succeed(1)
.delay(Duration::from_millis(100))
.fork() // Run in a separate fiber
.flat_map(|fiber| {
println!("Fiber started!");
fiber.join() // Wait for result
})
.map(|res| println!("Result: {}", res));
rt.block_on(program, ());
}
Effect-rs aims to bridge the gap between Rust's zero-cost abstractions and the expressive power of functional programming. By treating side effects as values, we gain:
The project includes several examples demonstrating key features. You can run them using the provided Makefile:
make run-bankmake run-streammake run-httpPerformance benchmarks are available for core components:
make benchmake bench-fibermake bench-runtimemake bench-stmmake bench-streamOr using Cargo directly:
cargo run --example transactional_bank
This project is licensed under the MIT License.