Semimonad

Trait Semimonad 

Source
pub trait Semimonad: Kind0L1T {
    // Required method
    fn bind<'a, ClonableFnBrand: 'a + ClonableFn, A: 'a + Clone, B: Clone>(
        ma: Apply0L1T<Self, A>,
    ) -> ApplyFn<'a, ClonableFnBrand, ApplyFn<'a, ClonableFnBrand, A, Apply0L1T<Self, B>>, Apply0L1T<Self, B>>;
}
Expand description

Sequences two computations, allowing the second to depend on the value computed by the first.

If x has type m a and f has type a -> m b, then bind(x)(f) has type m b, representing the result of executing x to get a value of type a and then passing it to f to get a computation of type m b.

Required Methods§

Source

fn bind<'a, ClonableFnBrand: 'a + ClonableFn, A: 'a + Clone, B: Clone>( ma: Apply0L1T<Self, A>, ) -> ApplyFn<'a, ClonableFnBrand, ApplyFn<'a, ClonableFnBrand, A, Apply0L1T<Self, B>>, Apply0L1T<Self, B>>

Sequences two computations, allowing the second to depend on the value computed by the first.

§Type Signature

forall a b. Semimonad m => m a -> (a -> m b) -> m b

§Parameters
  • ma: The first computation in the context.
  • f: A function that takes the result of the first computation and returns the second computation in the context.
§Returns

A computation that sequences the two operations.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl Semimonad for IdentityBrand

Source§

impl Semimonad for OptionBrand

Source§

impl Semimonad for VecBrand

Source§

impl<E> Semimonad for ResultWithErrBrand<E>
where for<'a> E: 'a + Clone,

Source§

impl<First> Semimonad for PairWithFirstBrand<First>
where for<'a> Apply1L0T<'a, First>: Semigroup<'a>, for<'a> First: Semigroup1L0T<Output<'a> = First> + Semigroup1L0T + Clone,

Source§

impl<Second> Semimonad for PairWithSecondBrand<Second>
where for<'a> Apply1L0T<'a, Second>: Semigroup<'a>, for<'a> Second: Semigroup1L0T<Output<'a> = Second> + Clone,

Source§

impl<T> Semimonad for ResultWithOkBrand<T>
where for<'a> T: 'a + Clone,