pub fn map_err() -> Term
Expand description

Applied to a function and a lambda-encoded Result it applies the function to the contents of the Result if it is Err.

MAP_ERR ≡ λfm.m OK (λx.ERR (f x)) ≡ λ λ 1 OK (λ ERR (3 1))

Example

use lambda_calculus::data::result::map_err;
use lambda_calculus::data::num::church::succ;
use lambda_calculus::*;

let ok_one: Result<usize, usize> = Ok(1);
let err_two: Result<usize, usize> = Err(2);
let err_three: Result<usize, usize> = Err(3);

assert_eq!(beta(app!(map_err(), succ(), ok_one.into_church()), NOR, 0), ok_one.into_church());
assert_eq!(beta(app!(map_err(), succ(), err_two.into_church()), NOR, 0), err_three.into_church());