effectful/foundation/mod.rs
1//! **Stratum 0: Foundations** — the categorical bedrock upon which all effect abstractions rest.
2//!
3//! This module provides the primitive mathematical constructs that form the basis of the
4//! effect system. Every higher-level abstraction (functors, monads, effects, streams) is
5//! ultimately built from these foundations.
6//!
7//! ## Core Constructs
8//!
9//! | Module | Construct | Category Theory |
10//! |--------|-----------|-----------------|
11//! | [`unit`] | `()` | Terminal object |
12//! | [`never`] | `Never` | Initial object |
13//! | [`function`] | `identity`, `compose`, `const_` | Morphisms |
14//! | [`product`] | `(A, B)`, `fst`, `snd`, `pair` | Categorical product |
15//! | [`coproduct`] | `Either<L, R>`, `left`, `right` | Categorical coproduct |
16//! | [`isomorphism`] | `Iso<A, B>` | Isomorphic objects |
17//!
18//! ## Practical Utilities (Effect.ts mirrors)
19//!
20//! | Module | Construct |
21//! |--------|-----------|
22//! | [`either`] | `Either<R,L>` alias + Effect.ts-named combinators |
23//! | [`func`] | `identity`, `compose`, `memoize`, `tupled` (full set) |
24//! | [`option_`] | Free functions over `Option<T>` |
25//! | [`piping`] | [`Pipe`] trait (`x.pipe(f)`) |
26//! | [`predicate`] | [`Predicate<A>`] composable boolean functions |
27//! | [`mutable_ref`] | [`MutableRef<A>`] synchronous interior-mutable cell |
28//!
29//! ## Laws
30//!
31//! - **Identity**: `compose(f, identity) ≡ f ≡ compose(identity, f)`
32//! - **Associativity**: `compose(f, compose(g, h)) ≡ compose(compose(f, g), h)`
33
34pub mod coproduct;
35pub mod either;
36pub mod func;
37pub mod function;
38pub mod isomorphism;
39pub mod mutable_ref;
40pub mod never;
41pub mod option_;
42pub mod piping;
43pub mod predicate;
44pub mod product;
45pub mod unit;
46
47pub use coproduct::{Either, either, left, right};
48pub use function::{absurd, always, compose, const_, flip, identity, pipe1, pipe2, pipe3};
49pub use isomorphism::Iso;
50pub use mutable_ref::MutableRef;
51pub use never::Never;
52pub use piping::Pipe;
53pub use predicate::Predicate;
54pub use product::{bimap_product, fst, pair, snd, swap};
55pub use unit::Unit;