Core concepts
This section defines the plgg ethos — the handful of ideas every package in the family assumes. It is the single source of truth: the per-package pages link back here instead of re-explaining Option, Result, cast, proc, and match.
The whole library follows a few rules:
- Type-driven — model the domain in types first, so the compiler rejects illegal states before they run.
- Absence is a value — use
Option, nevernull/undefined. - Errors are values — use
Result, neverthrow; expected failures are tagged data you fold by tag. - Data-last composition — build behavior by piping values through functions, config-first / data-last.
- Exhaustive handling — fold unions with
match; the compiler flags a missing case.
The concepts
- Tagged data (
Box) — theBox<Tag, Content>foundation everything is built on. - Option, not null — absence as a first-class value.
- Result, not throw — errors as tagged data flowing through the happy path.
- Validation with
cast— turnunknowninto typed values, accumulating errors. - Async with
proc— pipelines over promises and results, with precise error types. - Exhaustive
match— pattern matching that the compiler checks for completeness. - Data-last composition —
pipeandflow, and the config-first idiom.
Once these are familiar, the API details live on the core package pages: Values & effects and Structures & errors.