fp_library/typeclasses/
bind.rs1use crate::hkt::{Apply, Kind};
2
3pub trait Bind {
4 fn bind<F, A, B>(ma: Apply<Self, (A,)>) -> impl Fn(F) -> Apply<Self, (B,)>
6 where
7 Self: Kind<(A,)> + Kind<(B,)> + Sized,
8 Apply<Self, (A,)>: Clone,
9 F: Fn(A) -> Apply<Self, (B,)>;
10}
11
12pub fn bind<Brand, F, A, B>(ma: Apply<Brand, (A,)>) -> impl Fn(F) -> Apply<Brand, (B,)>
14where
15 Brand: Kind<(A,)> + Kind<(B,)> + Bind,
16 Apply<Brand, (A,)>: Clone,
17 F: Fn(A) -> Apply<Brand, (B,)>,
18{
19 move |f| Brand::bind::<F, A, B>(ma.to_owned())(f)
20}