Skip to main content

Module foundation

Module foundation 

Source
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

ModuleConstructCategory Theory
[unit]()Terminal object
[never]NeverInitial object
functionidentity, compose, const_Morphisms
product(A, B), fst, snd, pairCategorical product
coproductEither<L, R>, left, rightCategorical coproduct
isomorphismIso<A, B>Isomorphic objects

§Practical Utilities (Effect.ts mirrors)

ModuleConstruct
[either]Either<R,L> alias + Effect.ts-named combinators
funcidentity, compose, memoize, tupled (full set)
option_Free functions over Option<T>
pipingPipe trait (x.pipe(f))
predicatePredicate<A> composable boolean functions
mutable_refMutableRef<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.ts Either.
func
Higher-order function utilities — mirrors Effect.ts Function namespace.
function
Functions — morphisms in the category of types.
isomorphism
Isomorphism — invertible mappings between types.
mutable_ref
Synchronous interior-mutable cell — mirrors Effect.ts MutableRef style API.
never
Never — the initial object in the category of types.
option_
Free-function combinators over Option<T> — mirrors the Effect.ts Option namespace.
piping
Left-to-right function application (F#-style |>).
predicate
Composable predicates — mirrors Effect.ts Predicate namespace.
product
Product — the categorical product of types.
unit
Unit — the terminal object in the category of types.