fp_library/typeclasses/
apply_first.rs

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