A pure abstraction representing the intention to perform a side effect, where the result of that side effect is obtained synchronously.
SyncIO is similar to IO, but does not support asynchronous computations. Consequently,
a SyncIO can be run synchronously on any platform to obtain a result via unsafeRunSync.
This is unlike IO#unsafeRunSync, which cannot be safely called in general -- doing so on
the JVM blocks the calling thread while the async part of the computation is run and doing so
on Scala.js is not supported.
- Companion:
- object
Value members
Concrete methods
Materializes any sequenced exceptions into value space, where they may be handled.
Materializes any sequenced exceptions into value space, where they may be handled.
This is analogous to the catch clause in try/catch, being the inverse of
SyncIO.raiseError. Thus:
SyncIO.raiseError(ex).attempt.unsafeRunSync === Left(ex)
- See also:
Monadic bind on SyncIO, used for sequentially composing two SyncIO actions, where the
value produced by the first SyncIO is passed as input to a function producing the second
SyncIO action.
Monadic bind on SyncIO, used for sequentially composing two SyncIO actions, where the
value produced by the first SyncIO is passed as input to a function producing the second
SyncIO action.
Due to this operation's signature, flatMap forces a data dependency between two SyncIO
actions, thus ensuring sequencing (e.g. one action to be executed before another one).
Any exceptions thrown within the function will be caught and sequenced in to the result
SyncIO[B].
- Value parameters:
- f
the bind function
- Returns:
SyncIOproduced by applyingfto the result of the currentSyncIO
Handle any error, potentially recovering from it, by mapping it to another SyncIO value.
Handle any error, potentially recovering from it, by mapping it to another SyncIO value.
Implements ApplicativeError.handleErrorWith.
Functor map on SyncIO. Given a mapping function, it transforms the value produced by the
source, while keeping the SyncIO context.
Functor map on SyncIO. Given a mapping function, it transforms the value produced by the
source, while keeping the SyncIO context.
Any exceptions thrown within the function will be caught and sequenced into the result
SyncIO[B].
- Value parameters:
- f
the mapping function
- Returns:
SyncIOthat evaluates to the value obtained by applyingfto the result of the currentSyncIO
Executes that only for the side effects.
Executes that only for the side effects.
- Value parameters:
- that
SyncIOto be executed after thisSyncIO
- Returns:
SyncIOwhich sequences the effects ofthatbut evaluates to the result of thisSyncIO
Sequences that without propagating the value of the current SyncIO.
Sequences that without propagating the value of the current SyncIO.
- Value parameters:
- that
SyncIOto be executed after thisSyncIO
- Returns:
SyncIOwhich sequences the effects ofthat
Produces the result by running the encapsulated effects as impure side effects.
Produces the result by running the encapsulated effects as impure side effects.
Any exceptions raised within the effect will be re-thrown during evaluation.
As the name says, this is an UNSAFE function as it is impure and performs side effects and throws exceptions. You should ideally only call this function once, at the very end of your program.
- Returns:
the result of evaluating this
SyncIO