Enum operational::Program [] [src]

pub enum Program<'a, I: Instr, A> {
    Pure(Box<A>),
    Then(Box<I>, Kleisli<'a, I, I::Return, A>),
}

Represents a program, i.e. a sequence of instructions.

Variants

Pure

The case Pure(a) means that the program contains no instructions and just returns the result a.

Then

The case Then(instr, k) means that the first instruction is instr and the remaining program is given by the kleisli arrow k.

Methods

impl<'a, I: 'a + Instr, A> Program<'a, I, A>

fn and_then<B, F>(self, js: F) -> Program<'a, I, B> where F: 'a + Fn(A) -> Program<'a, I, B>

Appends a continuation to a program. Which means, given a function from A to Program<I, B>, passes the return value of the program to the function, and returns the resulting program.

Equivalent to the monadic >>= operator.

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

Modifies the return value of the program. Seen differently, it lifts a function from A to B into a function from Program<I, A> to Program<I, B>.

Equivalent to the monadic liftM.

Trait Implementations

impl<'a, I: 'a + Instr, A: PartialEq> PartialEq for Program<'a, I, A>

fn eq(&self, other: &Program<'a, I, A>) -> bool

fn ne(&self, other: &Rhs) -> bool

impl<'a, I: 'a + Instr, A: Debug> Debug for Program<'a, I, A>

fn fmt(&self, f: &mut Formatter) -> Result