lubeck 0.0.0-prealpha.5-abandoned

Functional programming framework written in cutting edge rust
Documentation
use crate::prelude::Functor;

use super::def::State;

impl<'a, S, A> Functor<'a, A> for State<'a, S, A>
where
    S: Clone + 'a,
    A: 'a,
{
    fn fmap<F, B>(self, f: F) -> Self::Type<B>
    where
        F: Fn(A) -> B + 'a,
        B: 'a,
    {
        Self::Type::<B> {
            run_state: Some(Box::new(move |s| {
                // S -> (A, S)
                let (a, st) = self.run(s);
                // (A, S) -> (B, S)
                let (b, st) = (f(a), st);
                (b, st)
            })),
        }
    }
}