fp_library/typeclasses/
apply_second.rs

1use crate::hkt::{Apply, Kind};
2
3pub trait ApplySecond {
4	/// forall a b. ApplySecond f => f a -> f b -> f b
5	fn apply_second<A, B>(fa: Apply<Self, (A,)>) -> impl Fn(Apply<Self, (B,)>) -> Apply<Self, (B,)>
6	where
7		Self: Kind<(A,)> + Kind<(B,)>,
8		Apply<Self, (A,)>: Clone,
9		B: Clone;
10}
11
12/// forall a b. ApplySecond f => f a -> f b -> f b
13pub fn apply_second<Brand, A, B>(
14	fa: Apply<Brand, (A,)>
15) -> impl Fn(Apply<Brand, (B,)>) -> Apply<Brand, (B,)>
16where
17	Brand: Kind<(A,)> + Kind<(B,)> + ApplySecond,
18	Apply<Brand, (A,)>: Clone,
19	B: Clone,
20{
21	Brand::apply_second::<A, B>(fa)
22}