1use crate::Bifunctor;
2use higher::Bilift;
3
4pub trait Profunctor<A, B, C, D>: Bilift<A, B, C, D> + Bifunctor<C, B, A, D> {
9 fn dimap<L, R>(self, left: L, right: R) -> <Self as Bilift<A, B, C, D>>::Target
10 where
11 L: Fn(C) -> A,
12 R: Fn(B) -> D;
13}
14
15pub trait ProfunctorLeft<A, B, C>: Profunctor<A, B, C, B> {
16 fn lcmap<F>(self, f: F) -> <Self as Bilift<A, B, C, B>>::Target
17 where
18 F: Fn(C) -> A;
19}
20
21impl<A, B, C> ProfunctorLeft<A, B, C> for A
22where
23 A: Profunctor<A, B, C, B>,
24{
25 fn lcmap<F>(self, f: F) -> <Self as Bilift<A, B, C, B>>::Target
26 where
27 F: Fn(C) -> A,
28 {
29 self.dimap(f, |a| a)
30 }
31}