plgg
plgg

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, never null/undefined.
  • Errors are values — use Result, never throw; 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

  1. Tagged data (Box) — the Box<Tag, Content> foundation everything is built on.
  2. Option, not null — absence as a first-class value.
  3. Result, not throw — errors as tagged data flowing through the happy path.
  4. Validation with cast — turn unknown into typed values, accumulating errors.
  5. Async with proc — pipelines over promises and results, with precise error types.
  6. Exhaustive match — pattern matching that the compiler checks for completeness.
  7. Data-last compositionpipe and flow, and the config-first idiom.

Once these are familiar, the API details live on the core package pages: Values & effects and Structures & errors.