Skip to content

1.5.0: Resource, bracketCase, bracketE, sequence, traverse, race, either, timeout, both, delay, productR - #11

Merged
MarcelloDuarte merged 2 commits into
mainfrom
developing-1.5.0
Oct 15, 2026
Merged

MarcelloDuarte merged 2 commits into
mainfrom
developing-1.5.0

Conversation

@MarcelloDuarte

Copy link
Copy Markdown
Contributor

Builds on #10 (1.4.2); merge that first and this diff reduces to the 1.5.0 commit. Everything is additive.

Resources

  • Resource (Phunkie\Effect\IO\Resource): a bracket as a value. Resource::make($acquire, $release), use($f), map, flatMap (the inner resource is acquired inside the outer one and released first), pure, eval.
  • bracketCase($acquire, $use, $release): the release step receives an ExitCase, Completed or Error; Cancelled exists in the enum and is documented as not yet produced.
  • bracketE($acquire, $use, $release): the release step receives the error or null. bracket is now bracketE with the error ignored.

Combinators

  • sequence(array $ios) and traverse(array $values, $f) in Functions\io; blocking effects are awaited.
  • IO::productR($next), IO::delay($millis), IO::both($other) (sequential pair; parMap2 stays the parallel form).

Racing

  • IO::race($other, $context = null), IO::either(...) returning Left/Right, IO::timeout($millis, $context = null) raising Concurrent\TimeoutException after cancelling. They start effects where they can be polled and cancelled: a blocking effect in its own context, anything else in the context given, ParallelExecutionContext by default. The fiber context is refused with a RuntimeException that explains why.
  • Concurrent\CancellableHandle (isDone, cancel) extends AsyncHandle; the parallel context's handle implements it on parallel\Future.

Specs

ResourceTest, BracketCaseTest, sequenceTest, CombinatorsTest, RacingTest. Racing is specified against a scripted execution context whose computations finish after a scripted number of polls, so the outcomes do not depend on timing; the one real race on ParallelExecutionContext is skipped without ext-parallel, like the existing parallel tests. 101 tests.

Docs

The sections pruned in 1.4.2 come back rewritten against this API, plus a Resource section, and the docs index and README list them. Channel and cancel on fiber handles stay out.

@MarcelloDuarte
MarcelloDuarte merged commit c0138a1 into main Oct 15, 2026
12 checks passed
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