id_effect 0.9.0

Effect<A, E, R>: lazy Send effects over a typed capability list, run on a fiber runtime (Tokio executor), with layers, streams, schedules and coordination
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//! Ex 011 — `map_err` rewrites the typed failure.
use id_effect::{Cause, Exit};
use id_effect::{Effect, effect};

fn parse_i32(raw: &'static str) -> Effect<i32, &'static str> {
  effect!({ raw.parse::<i32>().map_err(|_| "parse_failed")? })
}

fn main() {
  let program: Effect<i32, &'static str> = effect!({
    let v = ~parse_i32("nope").map_err(|_| "bad_input");
    v
  });
  assert_eq!(program.block_on(), Exit::Failure(Cause::Fail("bad_input")));
  println!("011_map_error ok");
}