pub trait Monad<B>: Applicative<B> {
    fn bind<F>(&self, f: F) -> Self::M
    where
        F: Fn(&Self::A) -> Self::M
; }
Expand description

Monad type class

Required methods

Bind works like map but it flattens nested structures

Examples
use funlib::Applicative;
use funlib::Monad;
fn over5(i: &i32) -> Option<i32> { if *i > 5 { Some(*i) } else { None }}
let a = Some(4).bind(over5);
let b = Some(6).bind(over5);
assert_eq!(None, a);
assert_eq!(Some(6), b);

Implementations on Foreign Types

Implementors