diff --git a/src/standard/writer.rs b/src/standard/writer.rs index 25227f6..f824427 100644 --- a/src/standard/writer.rs +++ b/src/standard/writer.rs @@ -5,6 +5,7 @@ */ use crate::core::hkp::HKP; +use crate::specs::functor::Functor; use std::marker::PhantomData; pub struct Writer<'a, E: 'a, F: HKP<'a>, A: 'a>(F::T<(A, E)>); @@ -14,3 +15,13 @@ pub struct WriterK<'a, E, F: HKP<'a>>(PhantomData<&'a E>, PhantomData); impl<'a, E, F: HKP<'a>> HKP<'a> for WriterK<'a, E, F> { type T = Writer<'a, E, F, B>; } + +impl<'e, E, F: Functor<'e>> Functor<'e> for WriterK<'e, E, F> { + fn map(f: MAP, ma: Self::T) -> Self::T + where + MAP: Fn(A) -> B + 'e, + { + let Writer(va) = ma; + Writer(F::map(move |(a, e)| (f(a), e), va)) + } +}