diff --git a/book-monads b/book-monads index 5848712..80aa72c 160000 --- a/book-monads +++ b/book-monads @@ -1 +1 @@ -Subproject commit 58487121898c8da9c51479f1df4c1055c7df1e6d +Subproject commit 80aa72c60ecd0ac605041d22df2ea6a66178c5be diff --git a/src/func.rs b/src/func.rs index 7fce1da..1e2789b 100644 --- a/src/func.rs +++ b/src/func.rs @@ -7,6 +7,7 @@ //! * //! * +mod applicative_select; pub mod classes; pub mod clone_func; mod controlflow; @@ -21,6 +22,7 @@ pub use std::ops::ControlFlow; pub use radn_derive::{CovariantFunctor, SharedFunctor}; +pub use self::applicative_select::{ApplicativeSelect, Selected}; pub use self::controlflow::{AIterative, AIterativeWrapped, Iterative, IterativeWrapped}; use self::controlflow::{ArgumentedIterative, BindableMut, ControlFlowClass}; diff --git a/src/func/applicative_select.rs b/src/func/applicative_select.rs new file mode 100644 index 0000000..e3914bb --- /dev/null +++ b/src/func/applicative_select.rs @@ -0,0 +1,16 @@ +use super::*; + +pub enum Selected<'a, A: 'a, B: 'a, T: ?Sized + 'a + WeakFunctor> { + A(A, T::F<'a, B>), + B(T::F<'a, A>, B), +} + +pub trait ApplicativeSelect: Functor { + fn select<'a, A: 'a, B: 'a, C: 'a>( + f: impl 'a + FnOnce(Selected<'a, A, B, Self>) -> C, + fa: Self::F<'a, A>, + fb: Self::F<'a, B>, + ) -> Self::F<'a, C> + where + Self: 'a; +}