Repository navigation
1.5.0: Resource, bracketCase, bracketE, sequence, traverse, race, either, timeout, both, delay, productR - #11
Merged
Merged
Conversation
…lay, both, race, either and timeout
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 anExitCase,CompletedorError;Cancelledexists in the enum and is documented as not yet produced.bracketE($acquire, $use, $release): the release step receives the error ornull.bracketis nowbracketEwith the error ignored.Combinators
sequence(array $ios)andtraverse(array $values, $f)inFunctions\io; blocking effects are awaited.IO::productR($next),IO::delay($millis),IO::both($other)(sequential pair;parMap2stays the parallel form).Racing
IO::race($other, $context = null),IO::either(...)returningLeft/Right,IO::timeout($millis, $context = null)raisingConcurrent\TimeoutExceptionafter cancelling. They start effects where they can be polled and cancelled: a blocking effect in its own context, anything else in the context given,ParallelExecutionContextby default. The fiber context is refused with aRuntimeExceptionthat explains why.Concurrent\CancellableHandle(isDone,cancel) extendsAsyncHandle; the parallel context's handle implements it onparallel\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 onParallelExecutionContextis skipped withoutext-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.
Channelandcancelon fiber handles stay out.