Trait Functor
funlib
pub trait Functor<B>: HKT<B> { fn fmap<F>(&self, f: F) -> Self::M where F: Fn(&Self::A) -> B; }
Functor type class
fn fmap<F>(&self, f: F) -> Self::M where F: Fn(&Self::A) -> B,
Functor map
use funlib::Functor; let n = Some(1).fmap(|i| i * 4); assert_eq!(Some(4), n);
impl<A, B> Functor<B> for Option<A>
fn fmap<F>(&self, f: F) -> Option<B> where F: Fn(&A) -> B,
impl<A, B> Functor<B> for Box<A>
fn fmap<F>(&self, f: F) -> Box<B> where F: Fn(&A) -> B,
impl<A, B> Functor<B> for Rc<A>
fn fmap<F>(&self, f: F) -> Rc<B> where F: Fn(&A) -> B,
impl<A, B> Functor<B> for Vec<A>
fn fmap<F>(&self, f: F) -> Vec<B> where F: Fn(&A) -> B,