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 F: Fn(A) -> Apply<Self, B>,
9 Apply<Self, A>: Clone;
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 F: Fn(A) -> Apply<Brand, B>,
17 Apply<Brand, A>: Clone,
18{
19 move |f| Brand::bind::<F, A, B>(ma.to_owned())(f)
20}