func::weakfunctorany
This commit is contained in:
parent
582dd76eab
commit
16c939e699
12
src/func.rs
12
src/func.rs
@ -21,6 +21,7 @@ pub mod shared;
|
||||
pub mod test_suite;
|
||||
#[cfg(test)]
|
||||
pub mod tests;
|
||||
pub mod weakfunctorany;
|
||||
|
||||
pub use self::applicative_select::{
|
||||
ApplicativeSelect, ApplicativeSelectExt, Selected, SelectedWrapped,
|
||||
@ -30,13 +31,6 @@ pub use self::extensions::MonadExt;
|
||||
#[cfg(doc)]
|
||||
use self::instances::stackless::StacklessInstance;
|
||||
|
||||
pub trait WeakFunctorAny {
|
||||
/// Type of the wrapped value.
|
||||
type FAny<'a, A: 'a>: 'a
|
||||
where
|
||||
Self: 'a;
|
||||
}
|
||||
|
||||
/// Part of Haskell's `Functor f` responsible for having `f a`.
|
||||
///
|
||||
/// <https://hackage.haskell.org/package/base-4.18.0.0/docs/Data-Functor.html>
|
||||
@ -44,10 +38,6 @@ pub trait WeakFunctor<'a>: 'a {
|
||||
type F<A: 'a>: 'a;
|
||||
}
|
||||
|
||||
impl<'a, T: ?Sized + 'a + WeakFunctorAny> WeakFunctor<'a> for T {
|
||||
type F<A: 'a> = T::FAny<'a, A>;
|
||||
}
|
||||
|
||||
pub type Wrap<'a, A, T> = <T as WeakFunctor<'a>>::F<A>;
|
||||
|
||||
/// Rust-specific implementation of [`Functor`], respecting `move` semantics.
|
||||
|
@ -5,9 +5,9 @@ pub use super::{
|
||||
instances,
|
||||
local::LocalFunctor,
|
||||
shared::{SharedFunctor, SharedFunctorAny},
|
||||
weakfunctorany::WeakFunctorAny,
|
||||
Applicative, ApplicativeLA2, ApplicativeSelect, ApplicativeSelectExt, ApplicativeSeq,
|
||||
ApplicativeTuple, Functor, Monad, Pure, Selected, SelectedWrapped, WeakFunctor, WeakFunctorAny,
|
||||
Wrap,
|
||||
ApplicativeTuple, Functor, Monad, Pure, Selected, SelectedWrapped, WeakFunctor, Wrap,
|
||||
};
|
||||
#[cfg(test)]
|
||||
pub use super::{test_suite, tests};
|
||||
|
@ -1,7 +1,9 @@
|
||||
use std::marker::PhantomData;
|
||||
pub use std::ops::ControlFlow;
|
||||
|
||||
use super::*;
|
||||
#[cfg(doc)]
|
||||
use super::Monad;
|
||||
use super::{weakfunctorany::WeakFunctorAny, Functor, Pure, WeakFunctor, Wrap};
|
||||
|
||||
pub struct ControlFlowInstance<C>(ControlFlow<(), C>);
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
use super::{weakfunctorany::WeakFunctorAny, WeakFunctor};
|
||||
pub use radn_derive::SharedFunctorAny;
|
||||
|
||||
use super::*;
|
||||
|
||||
pub trait SharedFunctorAny: WeakFunctorAny {
|
||||
type SharedAny<'a, A: 'a + Clone>: 'a + Clone
|
||||
where
|
||||
|
12
src/func/weakfunctorany.rs
Normal file
12
src/func/weakfunctorany.rs
Normal file
@ -0,0 +1,12 @@
|
||||
use super::WeakFunctor;
|
||||
|
||||
pub trait WeakFunctorAny {
|
||||
/// Type of the wrapped value.
|
||||
type FAny<'a, A: 'a>: 'a
|
||||
where
|
||||
Self: 'a;
|
||||
}
|
||||
|
||||
impl<'a, T: ?Sized + 'a + WeakFunctorAny> WeakFunctor<'a> for T {
|
||||
type F<A: 'a> = T::FAny<'a, A>;
|
||||
}
|
Loading…
Reference in New Issue
Block a user