← ZIO Direct docs

WithIR

zio.direct.core.metaprog.WithIR
trait WithIR

Attributes

Source
WithIR.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class Transformer[F, F_out, S, W, MM]
Self type

Members list

Type members

Classlikes

protected object IR

Attributes

Companion
trait
Source
WithIR.scala
Supertypes
class Object
trait Matchable
class Any
Self type
IR.type
sealed protected trait IR

Attributes

Companion
object
Source
WithIR.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait Leaf
class Monad
class Pure
trait Monadic
class And
class Block
class Fail
class FlatMap
class Foreach
class If
class Map
class Match
class Or
class Parallel
class Try
class Unsafe
class ValDef
class While
Show all
protected object IRT

Attributes

Companion
trait
Source
WithIR.scala
Supertypes
class Object
trait Matchable
class Any
Self type
IRT.type
sealed protected trait IRT

Attributes

Companion
object
Source
WithIR.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait Leaf
class Monad
class Pure
trait Monadic
class And
class Block
class Fail
class FlatMap
class Foreach
class If
class Map
class Match
class Or
class Parallel
class Try
class Unsafe
class ValDef
class While
Show all

Attributes

Source
WithIR.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class WrapUnsafes[F, S, W]
class WrapUnsafes[F[_, _, _], S, W](monad: DirectMonad[F, S, W])(implicit evidence$1: Type[F], evidence$2: Type[S], evidence$3: Type[W]) extends StatelessTransformer

Attributes

Companion
object
Source
WithIR.scala
Supertypes
class Object
trait Matchable
class Any
object WrapUnsafes

Wrap the IR.Pures/IR.Maps in the body of IR.Unsafe elements with ZIO.attempt. This is largely for the sake of tries working as expected, for example. (assume all the above examples are wrapped in defer { ... }) try { 1/0 } catch { case e: DivideByZeroException => ... } Normally with zio-run this will not be caught because 1/0 will not be wrapped into a ZIO.attempt. This statement will become succeed(1/0).catchSome { case e: ... } Instead we need it to become attempt(1/0).catchSome { case e: ... } This phase will do that.

Wrap the IR.Pures/IR.Maps in the body of IR.Unsafe elements with ZIO.attempt. This is largely for the sake of tries working as expected, for example. (assume all the above examples are wrapped in defer { ... }) try { 1/0 } catch { case e: DivideByZeroException => ... } Normally with zio-run this will not be caught because 1/0 will not be wrapped into a ZIO.attempt. This statement will become succeed(1/0).catchSome { case e: ... } Instead we need it to become attempt(1/0).catchSome { case e: ... } This phase will do that.

Also in a statement like this try { val x = run(foo); 1/0 } catch { case e: ... } It will become run(foo).map(x => 1/0).catchSome { case e: ... } Instead we need it to become run(foo).flatMap(x => attempt(1/0)).catchSome { case e: ... }

Most interestingly, in a statement like this try { unsafe { (run(foo), 4/0, run(bar)) } } catch { case: e... } Normally it would turn into { collect(Chunk(foo, bar)).map(iter => { val par1 = iter.next; var par2 = iter.next; (par1, 4/0, bar) } We need it to become { collect(Chunk(foo, bar)).flatMap(iter => attempt { val par1 = iter.next; var par2 = iter.next; (par1, 4/0, bar) }

Attributes

Companion
class
Source
WithIR.scala
Supertypes
class Object
trait Matchable
class Any
Self type

Implicits

Implicits

implicit val macroQuotes: Quotes

Attributes

Source
WithIR.scala