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.
- Source
- SyncIO.scala
- Alphabetic
- By Inheritance
- SyncIO
- Serializable
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- def *>[B](that: SyncIO[B]): SyncIO[B]
Alias for
productR.Alias for
productR.- See also
- def <*[B](that: SyncIO[B]): SyncIO[A]
Alias for
productL.Alias for
productL.- See also
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def >>[B](that: => SyncIO[B]): SyncIO[B]
Alias for
flatMap(_ => that).Alias for
flatMap(_ => that).- See also
- def as[B](b: B): SyncIO[B]
Alias for
map(_ => b).Alias for
map(_ => b).- See also
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def attempt: SyncIO[Either[Throwable, A]]
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
catchclause intry/catch, being the inverse ofSyncIO.raiseError. Thus:SyncIO.raiseError(ex).attempt.unsafeRunSync === Left(ex)
- See also
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- def flatMap[B](f: (A) => SyncIO[B]): SyncIO[B]
Monadic bind on
SyncIO, used for sequentially composing twoSyncIOactions, where the value produced by the firstSyncIOis passed as input to a function producing the secondSyncIOaction.Monadic bind on
SyncIO, used for sequentially composing twoSyncIOactions, where the value produced by the firstSyncIOis passed as input to a function producing the secondSyncIOaction.Due to this operation's signature,
flatMapforces a data dependency between twoSyncIOactions, 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].- f
the bind function
- returns
SyncIOproduced by applyingfto the result of the currentSyncIO
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def handleErrorWith[B >: A](f: (Throwable) => SyncIO[B]): SyncIO[B]
Handle any error, potentially recovering from it, by mapping it to another
SyncIOvalue.Handle any error, potentially recovering from it, by mapping it to another
SyncIOvalue.Implements
ApplicativeError.handleErrorWith. - def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def map[B](f: (A) => B): SyncIO[B]
Functor map on
SyncIO.Functor map on
SyncIO. Given a mapping function, it transforms the value produced by the source, while keeping theSyncIOcontext.Any exceptions thrown within the function will be caught and sequenced into the result
SyncIO[B].- f
the mapping function
- returns
SyncIOthat evaluates to the value obtained by applyingfto the result of the currentSyncIO
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def productL[B](that: SyncIO[B]): SyncIO[A]
Executes
thatonly for the side effects.Executes
thatonly for the side effects.- that
SyncIOto be executed after thisSyncIO- returns
SyncIOwhich sequences the effects ofthatbut evaluates to the result of thisSyncIO
- def productR[B](that: SyncIO[B]): SyncIO[B]
Sequences
thatwithout propagating the value of the currentSyncIO.Sequences
thatwithout propagating the value of the currentSyncIO.- that
SyncIOto be executed after thisSyncIO- returns
SyncIOwhich sequences the effects ofthat
- def redeem[B](recover: (Throwable) => B, map: (A) => B): SyncIO[B]
- def redeemWith[B](recover: (Throwable) => SyncIO[B], bind: (A) => SyncIO[B]): SyncIO[B]
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def to[F[_]](implicit F: Sync[F]): F[A]
Translates this SyncIO to any
F[_]data type that implements Sync. - def toString(): String
- Definition Classes
- SyncIO → AnyRef → Any
- 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.
- returns
the result of evaluating this
SyncIO
- def void: SyncIO[Unit]
Alias for
map(_ => ()).Alias for
map(_ => ()).- See also
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()