1use crate::Fx;
2
3impl<'a, S: Clone, V: Clone> Fx<'a, S, V> {
4 pub fn provide<T: Clone>(self, s: S) -> Fx<'a, T, V> {
5 self.contra_map(|_t| s, |t, _s| t)
6 }
7
8 pub fn provide_part<A, B, C, F>(self, a: A, cmap: C, fmap: F) -> Fx<'a, B, V>
9 where
10 C: FnOnce(A, B) -> S + Clone + 'a,
11 F: FnOnce(B, S) -> B + Clone + 'a,
12 A: Clone + 'a,
13 B: Clone + 'a,
14 {
15 self.contra_map(|b: B| cmap(a, b), fmap)
16 }
17}
18
19impl<'a, A: Clone, B: Clone, V: Clone> Fx<'a, (A, B), V> {
20 pub fn provide_left(self, a: A) -> Fx<'a, B, V> {
21 self.provide_part(a, |a, b| (a, b), |_b, (_a, b)| b)
22 }
23}