[][src]Function canrun::goals::project::map_1

pub fn map_1<'a, A, AV, B, BV, D, AtoB, BtoA>(
    a: AV,
    b: BV,
    a_to_b: AtoB,
    b_to_a: BtoA
) -> Goal<'a, D> where
    A: UnifyIn<'a, D> + Debug + 'a,
    B: UnifyIn<'a, D> + Debug + 'a,
    AV: IntoVal<A>,
    BV: IntoVal<B>,
    D: DomainType<'a, A> + DomainType<'a, B>,
    AtoB: Fn(&A) -> B + 'a,
    BtoA: Fn(&B) -> A + 'a, 

Create a projection goal that allows deriving one resolved value from the other.

Functions must be provided to derive in both directions. Whichever value is resolved first will be used to derive the other.

use canrun::{Goal, all, unify, var, map_1};
use canrun::example::I32;

let (x, y) = (var(), var());
let goal: Goal<I32> = all![
    unify(1, x),
    map_1(x, y, |x| x + 1, |y| y - 1),
];
let result: Vec<_> = goal.query(y).collect();
assert_eq!(result, vec![2])