fp_library/typeclasses/
apply.rs1use crate::hkt::{Apply as App, Kind};
2
3pub trait Apply {
4 fn apply<F, A, B>(ff: App<Self, (F,)>) -> impl Fn(App<Self, (A,)>) -> App<Self, (B,)>
6 where
7 Self: Kind<(F,)> + Kind<(A,)> + Kind<(B,)>,
8 App<Self, (F,)>: Clone,
9 F: Fn(A) -> B,
10 A: Clone;
11}
12
13pub fn apply<Brand, F, A, B>(ff: App<Brand, (F,)>) -> impl Fn(App<Brand, (A,)>) -> App<Brand, (B,)>
15where
16 Brand: Kind<(F,)> + Kind<(A,)> + Kind<(B,)> + Apply,
17 App<Brand, (F,)>: Clone,
18 F: Fn(A) -> B,
19 A: Clone,
20{
21 move |fa| Brand::apply::<F, _, _>(ff.to_owned())(fa)
22}