Trait Monad

Source
pub trait Monad<U>: Applicative<U> {
    // Required method
    fn bind<F>(&self, fs: F) -> Self::T
       where F: FnMut(&Self::C) -> Self::T;

    // Provided methods
    fn return_(x: U) -> Self::T
       where Self: HKT<U, C = U> { ... }
    fn join<T>(&self) -> T
       where Self: HKT<U, T = T, C = T>,
             T: Clone { ... }
}

Required Methods§

Source

fn bind<F>(&self, fs: F) -> Self::T
where F: FnMut(&Self::C) -> Self::T,

Provided Methods§

Source

fn return_(x: U) -> Self::T
where Self: HKT<U, C = U>,

Source

fn join<T>(&self) -> T
where Self: HKT<U, T = T, C = T>, T: Clone,

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.

Implementations on Foreign Types§

Source§

impl<T, U> Monad<U> for Option<T>

Source§

fn bind<F>(&self, fs: F) -> Option<U>
where F: FnMut(&T) -> Option<U>,

Source§

impl<T, U> Monad<U> for Box<T>

Source§

fn bind<F>(&self, fs: F) -> Box<U>
where F: FnMut(&T) -> Box<U>,

Source§

impl<T, U> Monad<U> for Rc<T>

Source§

fn bind<F>(&self, fs: F) -> Rc<U>
where F: FnMut(&T) -> Rc<U>,

Source§

impl<T, U> Monad<U> for Arc<T>

Source§

fn bind<F>(&self, fs: F) -> Arc<U>
where F: FnMut(&T) -> Arc<U>,

Source§

impl<T, U> Monad<U> for Vec<T>

Source§

fn bind<F>(&self, fs: F) -> Vec<U>
where F: FnMut(&T) -> Vec<U>,

Implementors§