pub trait Monad: Applicative + Semimonad { }
Expand description
A type class for monads.
Monad
combines the capabilities of Applicative
and Semimonad
, providing
a powerful abstraction for sequencing computations with context.
Monads are more powerful than applicative functors because they allow the structure of subsequent computations to depend on the results of previous computations.
§Laws
Monad
instances must satisfy the following laws:
- Left identity:
bind(pure(a))(f) = f(a)
. - Right identity:
bind(m)(pure) = m
. - Associativity:
bind(bind(m)(f))(g) = bind(m)(x => bind(f(x))(g))
.
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§
impl<Brand> Monad for Brandwhere
Brand: Applicative + Semimonad,
Blanket implementation for the Monad
type class.
Any type that implements all the required supertraits automatically implements Monad
.