Struct operational::Kleisli [] [src]

pub struct Kleisli<'a, I: Instr<Return=A>, A, B> {
    // some fields omitted
}

The Kleisli arrow from A to Program<I, B>.

Methods

impl<'a, I: Instr<Return=A>, A> Kleisli<'a, I, A, A>

fn new() -> Kleisli<'a, I, A, A>

Creates the identity arrow.

Example

use operational::Kleisli;
use operational::instr::identity;

let k = Kleisli::new();
assert_eq!(k.run(42), identity(42));

impl<'a, I: 'a + Instr<Return=A>, A, B> Kleisli<'a, I, A, B>

fn append<F, C>(self, f: F) -> Kleisli<'a, I, A, C> where F: 'a + Fn(B) -> Program<'a, I, C>

Appends the given function to the tail of the arrow. This corresponds to closure composition at the codomain (post-composition).

Example

use operational::{Kleisli, point};
use operational::instr::identity;

let k = Kleisli::new().append(|x| point(x + 1));
assert_eq!(k.run(42), identity(43));

fn run(self, a: A) -> Program<'a, I, B>

Given an input, runs the arrow to completion and return the resulting program.