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}
10
11/// forall a b. ApplySecond f => f a -> f b -> f b
12pub fn apply_second<Brand, A, B>(
13	fa: Apply<Brand, (A,)>
14) -> impl Fn(Apply<Brand, (B,)>) -> Apply<Brand, (B,)>
15where
16	Brand: Kind<(A,)> + Kind<(B,)> + ApplySecond,
17	Apply<Brand, (A,)>: Clone,
18{
19	Brand::apply_second::<A, B>(fa)
20}