ApplicativeSelect

This commit is contained in:
AF 2023-05-22 10:11:47 +00:00
parent 45923c401e
commit b9cc2a7eed
3 changed files with 19 additions and 1 deletions

@ -1 +1 @@
Subproject commit 58487121898c8da9c51479f1df4c1055c7df1e6d Subproject commit 80aa72c60ecd0ac605041d22df2ea6a66178c5be

View File

@ -7,6 +7,7 @@
//! * <https://hackage.haskell.org/package/base-4.18.0.0/docs/Control-Applicative.html> //! * <https://hackage.haskell.org/package/base-4.18.0.0/docs/Control-Applicative.html>
//! * <https://hackage.haskell.org/package/base-4.18.0.0/docs/Control-Monad.html> //! * <https://hackage.haskell.org/package/base-4.18.0.0/docs/Control-Monad.html>
mod applicative_select;
pub mod classes; pub mod classes;
pub mod clone_func; pub mod clone_func;
mod controlflow; mod controlflow;
@ -21,6 +22,7 @@ pub use std::ops::ControlFlow;
pub use radn_derive::{CovariantFunctor, SharedFunctor}; pub use radn_derive::{CovariantFunctor, SharedFunctor};
pub use self::applicative_select::{ApplicativeSelect, Selected};
pub use self::controlflow::{AIterative, AIterativeWrapped, Iterative, IterativeWrapped}; pub use self::controlflow::{AIterative, AIterativeWrapped, Iterative, IterativeWrapped};
use self::controlflow::{ArgumentedIterative, BindableMut, ControlFlowClass}; use self::controlflow::{ArgumentedIterative, BindableMut, ControlFlowClass};

View File

@ -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;
}