Skip to main content

StateTF

Struct StateTF 

Source
pub struct StateTF<S, M>(/* private fields */);
Expand description

StateT monad transformer: adds mutable state to an inner monad.

StateTF<S, M>::Of<A> = Box<dyn Fn(S) -> M::Of<(S, A)>>

Unlike ReaderT, the state is threaded (modified) through computations. When the inner monad is IdentityF, this is equivalent to the State monad from karpal-core’s adjunction module.

Trait Implementations§

Source§

impl<S: Clone + 'static, M: ChainSt + 'static> ChainSt for StateTF<S, M>

Source§

fn chain_st<A: 'static, B: 'static>( fa: Box<dyn Fn(S) -> M::Of<(S, A)>>, f: impl Fn(A) -> Box<dyn Fn(S) -> M::Of<(S, B)>> + 'static, ) -> Box<dyn Fn(S) -> M::Of<(S, B)>>

Source§

impl<S: 'static, M: FunctorSt + 'static> FunctorSt for StateTF<S, M>

Source§

fn fmap_st<A: 'static, B: 'static>( fa: Box<dyn Fn(S) -> M::Of<(S, A)>>, f: impl Fn(A) -> B + 'static, ) -> Box<dyn Fn(S) -> M::Of<(S, B)>>

Source§

impl<S: 'static, M: HKT + 'static> HKT for StateTF<S, M>

Source§

type Of<A> = Box<dyn Fn(S) -> <M as HKT>::Of<(S, A)>>

Source§

impl<S: Clone + 'static, M: FunctorSt + 'static> MonadTrans<M> for StateTF<S, M>

Source§

fn lift<A: 'static>(ma: M::Of<A>) -> Box<dyn Fn(S) -> M::Of<(S, A)>>
where M::Of<A>: Clone,

Lift an inner monadic value into the transformer.

Auto Trait Implementations§

§

impl<S, M> Freeze for StateTF<S, M>

§

impl<S, M> RefUnwindSafe for StateTF<S, M>

§

impl<S, M> Send for StateTF<S, M>
where S: Send, M: Send,

§

impl<S, M> Sync for StateTF<S, M>
where S: Sync, M: Sync,

§

impl<S, M> Unpin for StateTF<S, M>
where S: Unpin, M: Unpin,

§

impl<S, M> UnsafeUnpin for StateTF<S, M>

§

impl<S, M> UnwindSafe for StateTF<S, M>
where S: UnwindSafe, M: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.