MonadEffect3

Trait MonadEffect3 

Source
pub trait MonadEffect3<E: Effect3>{
    // Required methods
    fn pure<T>(
        value: T,
    ) -> <E::HktWitness as HKT3<E::Fixed1, E::Fixed2>>::Type<T>;
    fn bind<T, U, Func>(
        effect: <E::HktWitness as HKT3<E::Fixed1, E::Fixed2>>::Type<T>,
        f: Func,
    ) -> <E::HktWitness as HKT3<E::Fixed1, E::Fixed2>>::Type<U>
       where Func: FnMut(T) -> <E::HktWitness as HKT3<E::Fixed1, E::Fixed2>>::Type<U>;
}
Expand description

Re-exports the MonadEffect3 trait for monadic operations in arity-3 effect systems. Monadic logic for an Arity 3 type after it has been partially applied via Effect3.

This trait provides the pure and bind operations for type-encoded effect systems that track two fixed effect types (e.g., Error and Warning/Log) alongside a primary value. It enables sequencing computations within such an effectful context.

§Type Parameters

  • E: A type that implements the Effect3 trait, providing the fixed effect types and the HKT witness for the underlying type constructor.

Required Methods§

Source

fn pure<T>(value: T) -> <E::HktWitness as HKT3<E::Fixed1, E::Fixed2>>::Type<T>

Lifts a pure value into the DSL’s Effect container (arity 3).

This creates an effectful value with no initial errors or warnings, containing only the provided pure value.

§Arguments
  • value: The pure value to lift.
§Returns

An effectful value of type E::HktWitness::Type<T>.

Source

fn bind<T, U, Func>( effect: <E::HktWitness as HKT3<E::Fixed1, E::Fixed2>>::Type<T>, f: Func, ) -> <E::HktWitness as HKT3<E::Fixed1, E::Fixed2>>::Type<U>
where Func: FnMut(T) -> <E::HktWitness as HKT3<E::Fixed1, E::Fixed2>>::Type<U>,

The core sequencing operation for arity 3 effect systems.

This method chains a computation f to an existing effectful value effect. If effect contains an error, the error is propagated. Otherwise, the function f is applied to the value within effect, and any warnings/logs are combined.

§Arguments
  • effect: The initial effectful value.
  • f: A function that takes the inner value of effect and returns a new effectful value.
§Returns

A new effectful value representing the chained computation.

§Type Parameters
  • T: The type of the value inside the initial effect.
  • U: The type of the value inside the resulting effect.
  • Func: The type of the binding function.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§