Trait hetseq::Functor
[−]
[src]
pub trait Functor<F> { type Output; fn fmap(self, _: F) -> Self::Output; }
Functor over heterogenous list
Example
#![cfg_attr(feature="nightly", feature(unsize, fn_traits, unboxed_closures))] #[macro_use] extern crate hetseq; use hetseq::{Functor, Queue}; #[cfg(not(feature="nightly"))] use hetseq::prelude::*; use std::fmt::Display; lambda![ let Formatter = |arg: Display| -> String { format!("{}", arg) } ]; fn main() { let queue = hqueue![1, 2.5]; let strings = queue.fmap(&Formatter); assert_eq!(strings, hqueue!["1".to_owned(), "2.5".to_owned()]); }
Associated Types
type Output
Result of mapping
Required Methods
Implementors
impl<F> Functor<F> for List<()> type Output = List<()>;
impl<'a, F> Functor<F> for &'a List<()> type Output = List<()>;
impl<F> Functor<F> for Queue<()> type Output = Queue<()>;
impl<'a, F> Functor<F> for &'a Queue<()> type Output = Queue<()>;
impl<F, H, T, O, U> Functor<F> for List<(H, T)> where
T: Functor<F, Output = U>,
F: FnMut<(H,), Output = O>, type Output = List<(O, U)>;impl<'a, F, H, T, O, U> Functor<F> for &'a mut List<(H, T)> where
&'a mut T: Functor<F, Output = U>,
F: FnMut<(&'a mut H,), Output = O>, type Output = List<(O, U)>;impl<'a, F, H, T, O, U> Functor<F> for &'a List<(H, T)> where
&'a T: Functor<F, Output = U>,
F: FnMut<(&'a H,), Output = O>, type Output = List<(O, U)>;impl<F, H, T, O, U> Functor<F> for Queue<(H, T)> where
H: for<'a> Functor<&'a mut F, Output = U>,
F: FnMut<(T,), Output = O>, type Output = Queue<(U, O)>;impl<'a, F, H, T, O, U> Functor<F> for &'a mut Queue<(H, T)> where
&'a mut H: for<'b> Functor<&'b mut F, Output = U>,
F: FnMut<(&'a mut T,), Output = O>, type Output = Queue<(U, O)>;impl<'a, F, H, T, O, U> Functor<F> for &'a Queue<(H, T)> where
&'a H: for<'b> Functor<&'b mut F, Output = U>,
F: FnMut<(&'a T,), Output = O>, type Output = Queue<(U, O)>;