MonadEffect5

Trait MonadEffect5 

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

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

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

§Type Parameters

  • E: A type that implements the Effect5 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 HKT5<E::Fixed1, E::Fixed2, E::Fixed3, E::Fixed4>>::Type<T>

Lifts a pure value into an Effect container (arity 5).

This creates an effectful value with no initial errors, logs, counters, or traces, 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 HKT5<E::Fixed1, E::Fixed2, E::Fixed3, E::Fixed4>>::Type<T>, f: Func, ) -> <E::HktWitness as HKT5<E::Fixed1, E::Fixed2, E::Fixed3, E::Fixed4>>::Type<U>
where Func: FnMut(T) -> <E::HktWitness as HKT5<E::Fixed1, E::Fixed2, E::Fixed3, E::Fixed4>>::Type<U>,

The core sequencing operation for arity 5 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 logs/counters/traces 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§