diff --git a/src/standard/reader.rs b/src/standard/reader.rs index 53e859f..0c8cf80 100644 --- a/src/standard/reader.rs +++ b/src/standard/reader.rs @@ -60,3 +60,61 @@ impl<'e, E: Copy, F: Bind<'e> + 'e> Bind<'e> for ReaderK<'e, E, F> { } impl<'e, E: Copy, F: Bind<'e> + 'e> Monad<'e> for ReaderK<'e, E, F> {} + +pub mod infix { + use crate::core::hkp::HKP; + use crate::core::transform::Transform; + use crate::specs::applicative::infix::Applicative; + use crate::specs::bind::infix::Bind; + use crate::specs::functor::infix::Functor; + use crate::specs::monad::infix::Monad; + use crate::standard::reader::{Reader, ReaderK}; + + impl<'a, E, F: HKP<'a>, A: 'a> HKP<'a> for Reader<'a, E, F, A> { + type T = Reader<'a, E, F, B>; + } + + impl<'a, E: 'a, F: HKP<'a>, A: 'a> Transform<'a, A> for Reader<'a, E, F, A> { + type This = ReaderK<'a, E, F>; + + fn hkp_to_self(a: >::T) -> Self::T { + a + } + + fn self_to_hkp(a: Self::T) -> >::T { + a + } + + fn to_hkp(self) -> >::T { + self + } + } + + impl<'a, E: 'a, F: HKP<'a> + crate::specs::functor::Functor<'a> + 'a, A: 'a> Functor<'a, A> + for Reader<'a, E, F, A> + { + type ThisL = ReaderK<'a, E, F>; + type TL = Reader<'a, E, F, B>; + } + + impl<'a, E: 'a + Copy, F: HKP<'a> + crate::specs::applicative::Applicative<'a> + 'a, A: 'a> + Applicative<'a, A> for Reader<'a, E, F, A> + { + type ThisL = ReaderK<'a, E, F>; + type TL = Reader<'a, E, F, B>; + } + + impl<'a, E: 'a + Copy, F: HKP<'a> + crate::specs::bind::Bind<'a> + 'a, A: 'a> Bind<'a, A> + for Reader<'a, E, F, A> + { + type ThisL = ReaderK<'a, E, F>; + type TL = Reader<'a, E, F, B>; + } + + impl<'a, E: 'a + Copy, F: HKP<'a> + crate::specs::monad::Monad<'a> + 'a, A: 'a> Monad<'a, A> + for Reader<'a, E, F, A> + { + type ThisL = ReaderK<'a, E, F>; + type TL = Reader<'a, E, F, B>; + } +}