Skip to main content

EitherTMonad

Struct EitherTMonad 

Source
pub struct EitherTMonad<M, E, A> {
    pub inner: Vec<OxiEither<A, E>>,
    /* private fields */
}
Expand description

A monad transformer wrapper representing M (Either E A).

EitherTMonad is a thin Rust-level encoding of the EitherT transformer, holding the inner monadic value as an OxiEither<A, E> wrapped in a Vec (as a stand-in for a generic monad M).

Fields§

§inner: Vec<OxiEither<A, E>>

The inner value, represented as M (Either E A). We use Vec as a concrete stand-in for the monad M.

Implementations§

Source§

impl<M, E: Clone, A: Clone> EitherTMonad<M, E, A>

Source

pub fn new(value: OxiEither<A, E>) -> Self

Wrap a single OxiEither value into the transformer.

Source

pub fn pure(a: A) -> Self

Lift a pure value into the transformer (right-inject).

Source

pub fn throw(e: E) -> Self

Fail with an error (left-inject).

Source

pub fn run(self) -> Option<OxiEither<A, E>>

Run the transformer, extracting the inner value.

Source

pub fn bind<B: Clone, F>(self, f: F) -> EitherTMonad<M, E, B>
where F: FnOnce(A) -> EitherTMonad<M, E, B>,

Bind over the transformer.

Source

pub fn map<B: Clone, F: FnOnce(A) -> B>(self, f: F) -> EitherTMonad<M, E, B>

Map over the success value.

Auto Trait Implementations§

§

impl<M, E, A> Freeze for EitherTMonad<M, E, A>

§

impl<M, E, A> RefUnwindSafe for EitherTMonad<M, E, A>

§

impl<M, E, A> Send for EitherTMonad<M, E, A>
where M: Send, A: Send, E: Send,

§

impl<M, E, A> Sync for EitherTMonad<M, E, A>
where M: Sync, A: Sync, E: Sync,

§

impl<M, E, A> Unpin for EitherTMonad<M, E, A>
where M: Unpin, A: Unpin, E: Unpin,

§

impl<M, E, A> UnsafeUnpin for EitherTMonad<M, E, A>

§

impl<M, E, A> UnwindSafe for EitherTMonad<M, E, A>
where M: UnwindSafe, A: UnwindSafe, E: 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.