Expand description
Stratum 0: Foundations — the categorical bedrock upon which all effect abstractions rest.
This module provides the primitive mathematical constructs that form the basis of the effect system. Every higher-level abstraction (functors, monads, effects, streams) is ultimately built from these foundations.
§Core Constructs
| Module | Construct | Category Theory |
|---|---|---|
[unit] | () | Terminal object |
[never] | Never | Initial object |
function | identity, compose, const_ | Morphisms |
product | (A, B), fst, snd, pair | Categorical product |
coproduct | Either<L, R>, left, right | Categorical coproduct |
isomorphism | Iso<A, B> | Isomorphic objects |
§Practical Utilities (Effect.ts mirrors)
| Module | Construct |
|---|---|
[either] | Either<R,L> alias + Effect.ts-named combinators |
func | identity, compose, memoize, tupled (full set) |
option_ | Free functions over Option<T> |
piping | Pipe trait (x.pipe(f)) |
predicate | Predicate<A> composable boolean functions |
mutable_ref | MutableRef<A> synchronous interior-mutable cell |
§Laws
- Identity:
compose(f, identity) ≡ f ≡ compose(identity, f) - Associativity:
compose(f, compose(g, h)) ≡ compose(compose(f, g), h)
Re-exports§
pub use coproduct::Either;pub use coproduct::either;pub use coproduct::left;pub use coproduct::right;pub use function::absurd;pub use function::always;pub use function::compose;pub use function::const_;pub use function::flip;pub use function::identity;pub use function::pipe1;pub use function::pipe2;pub use function::pipe3;pub use isomorphism::Iso;pub use mutable_ref::MutableRef;pub use never::Never;pub use piping::Pipe;pub use predicate::Predicate;pub use product::bimap_product;pub use product::fst;pub use product::pair;pub use product::snd;pub use product::swap;pub use unit::Unit;
Modules§
- coproduct
- Coproduct — the categorical coproduct (sum) of types.
- either
Either<R, L>type alias and free-function combinators — mirrors Effect.tsEither.- func
- Higher-order function utilities — mirrors Effect.ts
Functionnamespace. - function
- Functions — morphisms in the category of types.
- isomorphism
- Isomorphism — invertible mappings between types.
- mutable_
ref - Synchronous interior-mutable cell — mirrors Effect.ts
MutableRefstyle API. - never
- Never — the initial object in the category of types.
- option_
- Free-function combinators over
Option<T>— mirrors the Effect.tsOptionnamespace. - piping
- Left-to-right function application (F#-style
|>). - predicate
- Composable predicates — mirrors Effect.ts
Predicatenamespace. - product
- Product — the categorical product of types.
- unit
- Unit — the terminal object in the category of types.