Trait functional::Monad
[−]
[src]
pub trait Monad: Functor { fn unit(value: Self::Type) -> Self; fn bind<U, F: Fn(Self::Type) -> Self::Type>(self, f: F) -> Self::Type where Self: Rebind1<U>; fn join<U>(self) -> Self::Type where Self::Type: Equals<Self::Type>, Self: Rebind1<U> + Sized { ... } }
Monad trait. Can you explain monads... in five words?
Required Methods
fn unit(value: Self::Type) -> Self
Wrap ordinary value into monadic value
fn bind<U, F: Fn(Self::Type) -> Self::Type>(self, f: F) -> Self::Type where Self: Rebind1<U>
Bind monadic value to the monadic action
m.bind(f)
is equvalent of m.fmap(f).join()
Provided Methods
fn join<U>(self) -> Self::Type where Self::Type: Equals<Self::Type>, Self: Rebind1<U> + Sized
Join two level of monad into one M<M<T>> => M<T>
m.join()
is equivalent of m.bind(|x|x)
Implementors
impl<T> Monad for Option<T>