effectful 0.3.0

Effect<A, E, R> (sync + async), context/layers, pipe — interpreter-style, no bundled executor
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//! Ex 021 — `ctx!` builds a `Context` from key/value pairs.
use effectful::{Cons, Context, Get, Nil, Service, Tagged, ctx, run_blocking, succeed};

#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, Service)]
struct PortKey;

type Env = Context<Cons<Tagged<PortKey, u16>, Nil>>;

fn main() {
  let env: Env = ctx!(PortKey => 8080_u16);
  assert_eq!(*Get::<PortKey>::get(&env), 8080);
  assert_eq!(
    run_blocking(succeed::<(), (), Env>(()), env),
    Ok::<(), ()>(())
  );
  println!("021_ctx_macro ok");
}