Skip to main content

Module algebra

Module algebra 

Source
Expand description

Stratum 1: Algebraic Structures — abstract patterns that recur throughout the system.

This module provides the fundamental algebraic abstractions built on top of Stratum 0 foundations. These structures capture common patterns of composition, transformation, and combination.

§Hierarchy

                   Semigroup
                       │
                       ▼
                    Monoid

    Contravariant   Functor   Bifunctor
                       │
                       ▼
                  Applicative
                       │
                       ▼
                     Monad

§Design Notes

Rust lacks higher-kinded types, so we use two complementary approaches:

  1. Traits with associated types — for types with a single “mappable” parameter
  2. Module functions — for operations on concrete types (like Option, Result)

The traits express the structure, while module functions provide ergonomic usage.

Re-exports§

pub use applicative::Applicative;
pub use bifunctor::Bifunctor;
pub use contravariant::Contravariant;
pub use functor::Functor;
pub use monad::Monad;
pub use monoid::Monoid;
pub use selective::Selective;
pub use semigroup::Semigroup;

Modules§

applicative
Applicative — a functor with pure and apply operations.
bifunctor
Bifunctor — a functor in two type parameters.
contravariant
Contravariant — a functor with reversed variance.
functor
Functor — a type constructor that can be mapped over.
interface
EffectInterface — typed operation-signature protocol (Koka/Eff/Frank analogue).
monad
Monad — an applicative with sequential composition.
monoid
Monoid — a semigroup with an identity element.
selective
Selective — a functor between Applicative and Monad.
semigroup
Semigroup — a type with an associative binary operation.