Alias for <*>
and zip
.
Splits the environment, providing the first part to this effect and the second part to that effect.
Sequentially zips this value with the specified one, discarding the first element of the tuple.
Depending on provided environment, returns either this one or the other
effect lifted in Left
or Right
, respectively.
Sequentially zips this value with the specified one, discarding the second element of the tuple.
Sequentially zips this value with the specified one.
Propagates self environment to that.
Tries this effect first, and if it fails, tries the other effect.
Feeds the value produced by this effect to the specified function, and then runs the returned effect as well to produce its results.
Propagates the given environment to self.
Returns an effect that submerges the error case of an Either
into the
STM
.
Returns an effect that submerges the error case of an Either
into the
STM
. The inverse operation of STM.either
.
Named alias for >>>
.
Maps the success value of this effect to the specified constant value.
Maps the success value of this effect to an optional value.
Maps the error value of this effect to an optional value.
Returns an STM
effect whose failure and success channels have been mapped by
the specified pair of functions, f
and g
.
Recovers from all errors.
Recovers from some or all of the error cases.
Simultaneously filters and maps the value produced by this effect.
Simultaneously filters and flatMaps the value produced by this effect.
Simultaneously filters and flatMaps the value produced by this effect. Continues on the effect returned from pf.
Commits this transaction atomically.
Commits this transaction atomically, regardless of whether the transaction is a success or a failure.
Named alias for <<<
.
Repeats this STM
effect until its result satisfies the specified predicate.
Repeats this STM
effect while its result satisfies the specified predicate.
Converts the failure channel into an Either
.
Executes the specified finalization transaction whether or not this effect succeeds.
Executes the specified finalization transaction whether or not this effect succeeds. Note that as with all STM transactions, if the full transaction fails, everything will be rolled back.
Returns an effect that ignores errors and runs repeatedly until it eventually succeeds.
Dies with specified Throwable
if the predicate fails.
Dies with a java.lang.RuntimeException having the specified text message if the predicate fails.
Applies f
if the predicate fails.
Supplies zstm
if the predicate fails.
Fails with e
if the predicate fails.
Feeds the value produced by this effect to the specified function, and then runs the returned effect as well to produce its results.
Creates a composite effect that represents this effect followed by another one that may depend on the error produced by this one.
Flattens out a nested STM
effect.
Unwraps the optional error, defaulting to the provided value.
Flips the success and failure channels of this transactional effect.
Flips the success and failure channels of this transactional effect. This allows you to use all methods on the error channel, possibly before flipping back.
Swaps the error/value parameters, applies the function f
and flips the parameters back
Folds over the STM
effect, handling both failure and success, but not
retry.
Effectfully folds over the STM
effect, handling both failure and
success.
Repeats this effect forever (until the first error).
Unwraps the optional success of this effect, but can fail with unit value.
Returns a successful effect with the head of the list if the list is
non-empty or fails with the error None
if the list is empty.
Returns a new effect that ignores the success or failure of this effect.
Returns a successful effect if the value is Left
, or fails with the error None
.
Returns a successful effect if the value is Left
, or fails with the error e.
Returns a successful effect if the value is Left
, or fails with
a java.util.NoSuchElementException.
Maps the value produced by the effect.
Maps from one error type to another.
Returns a new effect where the error channel has been merged into the success channel to their common combined type.
Requires the option produced by this value to be None
.
Propagates the success value to the first element of a tuple, but
passes the effect input R
along unmodified as the second element
of the tuple.
Returns this effect if environment is on the left, otherwise returns whatever is on the right unmodified.
Returns this effect if environment is on the left, otherwise returns whatever is on the right unmodified. Note that the result is lifted in either.
Returns this effect if environment is on the right, otherwise returns whatever is on the left unmodified.
Returns this effect if environment is on the right, otherwise returns whatever is on the left unmodified. Note that the result is lifted in either.
Propagates the success value to the second element of a tuple, but
passes the effect input R
along unmodified as the first element
of the tuple.
Converts the failure channel into an Option
.
Converts an option on errors into an option on values.
Translates STM
effect failure into death of the fiber, making all failures unchecked and
not a part of the type of the effect.
Keeps none of the errors, and terminates the fiber running the STM
effect with them, using the specified function to convert the E
into a Throwable
.
Named alias for <>
.
Returns a transactional effect that will produce the value of this effect in left side, unless it fails, in which case, it will produce the value of the specified effect in right side.
Tries this effect first, and if it fails, fails with the specified error.
Tries this effect first, and if it fails, succeeds with the specified value.
Provides the transaction its required environment, which eliminates
its dependency on R
.
Provides some of the environment required to run this effect,
leaving the remainder R0
.
Keeps some of the errors, and terminates the fiber with the rest.
Keeps some of the errors, and terminates the fiber with the rest, using
the specified function to convert the E
into a Throwable
.
Fail with the returned value if the PartialFunction
matches, otherwise
continue with our held value.
Continue with the returned computation if the PartialFunction
matches,
translating the successful match into a failure, otherwise continue with
our held value.
Filters the value produced by this effect, retrying the transaction until the predicate returns true for the value.
Filters the value produced by this effect, retrying the transaction while the predicate returns true for the value.
Returns a successful effect if the value is Right
, or fails with the error None
.
Returns a successful effect if the value is Right
, or fails with the
given error 'e'.
Returns a successful effect if the value is Right
, or fails with
a java.util.NoSuchElementException.
Converts an option on values into an option on errors.
Extracts the optional value, or fails with the given error 'e'.
Extracts the optional value, or fails with a java.util.NoSuchElementException
Summarizes a STM
effect by computing a provided value before and after execution, and
then combining the values to produce a summary, together with the result of
execution.
"Peeks" at the success of transactional effect.
"Peeks" at both sides of an transactional effect.
"Peeks" at the error of the transactional effect.
Maps the success value of this effect to unit.
The moral equivalent of if (p) exp
The moral equivalent of if (p) exp
when p
has side-effects
Same as retryUntil.
Named alias for <*>
.
Named alias for <*
.
Named alias for *>
.
Sequentially zips this value with the specified one, combining the values using the specified combiner function.
Depending on provided environment returns either this one or the other effect.
Maps the error value of this effect to the specified constant value.
Maps the error value of this effect to the specified constant value.
(Since version 1.0.0) use orElseFail
Tries this effect first, and if it fails, succeeds with the specified value.
Tries this effect first, and if it fails, succeeds with the specified value.
(Since version 1.0.0) use orElseSucceed
STM[E, A]
represents an effect that can be performed transactionally, resulting in a failureE
or a valueA
.Software Transactional Memory is a technique which allows composition of arbitrary atomic operations. It is the software analog of transactions in database systems.
The API is lifted directly from the Haskell package Control.Concurrent.STM although the implementation does not resemble the Haskell one at all. http://hackage.haskell.org/package/stm-2.5.0.0/docs/Control-Concurrent-STM.html
STM in Haskell was introduced in: Composable memory transactions, by Tim Harris, Simon Marlow, Simon Peyton Jones, and Maurice Herlihy, in ACM Conference on Principles and Practice of Parallel Programming 2005. https://www.microsoft.com/en-us/research/publication/composable-memory-transactions/
See also: Lock Free Data Structures using STMs in Haskell, by Anthony Discolo, Tim Harris, Simon Marlow, Simon Peyton Jones, Satnam Singh) FLOPS 2006: Eighth International Symposium on Functional and Logic Programming, Fuji Susono, JAPAN, April 2006 https://www.microsoft.com/en-us/research/publication/lock-free-data-structures-using-stms-in-haskell/