Skip to content

Modernize ResourceT v2 with cancellation safety and structured concurrency - #5

Draft
robertdp wants to merge 2 commits into
masterfrom
revamp-modern-purescript
Draft

robertdp wants to merge 2 commits into
masterfrom
revamp-modern-purescript

Conversation

@robertdp

@robertdp robertdp commented Sep 2, 2026

Copy link
Copy Markdown
Owner

Summary

This prepares ResourceT 2.0 for PureScript 0.15.16 and Spago 1.0.4 while closing resource-ownership and cancellation gaps. Managed forks now use structured concurrency: a resource scope owns, awaits, and cancels its child fibers.

Key changes

  • replace the legacy Bower/Dhall setup with spago.yaml, registry package set 80.8.1, strict and pedantic builds, and committed lockfiles;
  • make allocate cancellation-safe across acquisition and registry insertion, while retaining acquire as an alias;
  • bind opaque release keys to their originating registry and provide atomic release and unprotect operations;
  • run remaining finalizers once in LIFO order and aggregate reportable body, child, and cleanup failures;
  • add nursery-backed scopes so managed children finish before parent resources are released;
  • rebuild Control.Monad.Resource.Aff.Pool on the nursery;
  • require Node.js 24 or newer for the repository toolchain;
  • update CI, package metadata, formatting, and the BSD-3-Clause license.

Consumer documentation

  • rewrite the README as the package overview and quick start;
  • add a focused guide for allocation, release keys, ownership transfer, managed children, error behavior, transformer stacks, and the compatibility pool;
  • expand generated API documentation at the public module boundary;
  • compile-check representative documentation examples in test/Docs.purs;
  • remove the changelog and migration material.

Important behavior

  • Control.Monad.Resource.fork and forkAff create managed children. Scope exit waits for them, and a failed or directly cancelled child fails the scope and cancels managed siblings.
  • Intentionally detached work uses Effect.Aff.forkAff directly and must not retain scoped resources.
  • allocate is the canonical acquisition API; acquire remains an alias.
  • Release keys are registry capabilities and cannot affect another scope.
  • External fiber cancellation attempts cleanup but suppresses cleanup errors because Aff has no error-return channel for finalizer failures on that path.

Validation

Run under Node.js 24.20.0:

  • npm ci
  • npm run format:check
  • npm test — 12/12 tests passed; strict/pedantic build produced no warnings or errors
  • npm run docs — documentation generated successfully
  • documentation examples compiled through the test build
  • relative documentation links and stale references checked
  • independent lifecycle and consumer-documentation reviews found no blocking or major issues

Spago's documentation search-index step emits non-fatal warnings for dependency purs.json metadata. The npm development toolchain reports seven inherited advisories; this package has no runtime npm dependencies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant