Skip to content

Commit

Permalink
Reader - Applicative - apply
Browse files Browse the repository at this point in the history
  • Loading branch information
d-plaindoux committed Sep 16, 2023
1 parent 7262560 commit 1ebea0a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/standard/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl<'e, E, F: Functor<'e> + 'e> Functor<'e> for ReaderK<'e, E, F> {
}
}

impl<'e, E, F: Applicative<'e> + 'e> Applicative<'e> for ReaderK<'e, E, F> {
impl<'e, E: Clone, F: Applicative<'e> + 'e> Applicative<'e> for ReaderK<'e, E, F> {
fn pure<A: 'e>(a: A) -> Self::T<A> {
Reader(Box::new(|_| F::pure(a)), PhantomData)
}
Expand All @@ -33,6 +33,9 @@ impl<'e, E, F: Applicative<'e> + 'e> Applicative<'e> for ReaderK<'e, E, F> {
A: Clone,
MAP: Fn(A) -> B,
{
todo!()
let Reader(vf, _) = mf;
let Reader(va, _) = ma;
let run = |e: E| F::apply(vf(e.clone()), va(e));
Reader(Box::new(run), PhantomData)
}
}

0 comments on commit 1ebea0a

Please sign in to comment.