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.
- The instructions are given by the type
I
. A
is the return type of the program.
Variants
Pure(Box<A>)
The case Pure(a)
means that the program contains no instructions and just returns the result a
.
Then(Box<I>, Kleisli<'a, I, I::Return, A>)
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>
[src]
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>
[src]
fn eq(&self, other: &Program<'a, I, A>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0
This method tests for !=
.