SyncIO

cats.effect.SyncIO
See theSyncIO companion object
sealed abstract class SyncIO[+A] extends Serializable

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.

Attributes

Companion:
object
Source:
SyncIO.scala
Graph
Supertypes
trait Serializable
class Object
trait Matchable
class Any

Members list

Concise view

Value members

Concrete methods

def *>[B](that: SyncIO[B]): SyncIO[B]

Alias for productR.

Alias for productR.

Attributes

See also:
Source:
SyncIO.scala
def <*[B](that: SyncIO[B]): SyncIO[A]

Alias for productL.

Alias for productL.

Attributes

See also:
Source:
SyncIO.scala
def >>[B](that: => SyncIO[B]): SyncIO[B]

Alias for flatMap(_ => that).

Alias for flatMap(_ => that).

Attributes

See also:
Source:
SyncIO.scala
def as[B](b: B): SyncIO[B]

Alias for map(_ => b).

Alias for map(_ => b).

Attributes

See also:
Source:
SyncIO.scala

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)

Attributes

See also:
Source:
SyncIO.scala
def flatMap[B](f: A => SyncIO[B]): SyncIO[B]

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].

Attributes

f

the bind function

Returns:

SyncIO produced by applying f to the result of the current SyncIO

Source:
SyncIO.scala
def handleErrorWith[B >: A](f: Throwable => SyncIO[B]): SyncIO[B]

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.

Attributes

Source:
SyncIO.scala
def map[B](f: A => B): SyncIO[B]

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].

Attributes

f

the mapping function

Returns:

SyncIO that evaluates to the value obtained by applying f to the result of the current SyncIO

Source:
SyncIO.scala
def productL[B](that: SyncIO[B]): SyncIO[A]

Executes that only for the side effects.

Executes that only for the side effects.

Attributes

that

SyncIO to be executed after this SyncIO

Returns:

SyncIO which sequences the effects of that but evaluates to the result of this SyncIO

Source:
SyncIO.scala
def productR[B](that: SyncIO[B]): SyncIO[B]

Sequences that without propagating the value of the current SyncIO.

Sequences that without propagating the value of the current SyncIO.

Attributes

that

SyncIO to be executed after this SyncIO

Returns:

SyncIO which sequences the effects of that

Source:
SyncIO.scala
def redeem[B](recover: Throwable => B, map: A => B): SyncIO[B]

Attributes

Source:
SyncIO.scala
def redeemWith[B](recover: Throwable => SyncIO[B], bind: A => SyncIO[B]): SyncIO[B]

Attributes

Source:
SyncIO.scala
def to[F[_]](implicit F: Sync[F]): F[A]

Translates this SyncIO to any F[_] data type that implements Sync.

Translates this SyncIO to any F[_] data type that implements Sync.

Attributes

Source:
SyncIO.scala
override def toString(): String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns:

a string representation of the object.

Definition Classes
Any
Source:
SyncIO.scala
def unsafeRunSync(): A

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.

Attributes

Returns:

the result of evaluating this SyncIO

Source:
SyncIO.scala

Alias for map(_ => ()).

Alias for map(_ => ()).

Attributes

See also:
Source:
SyncIO.scala