Skip to content

Commit

Permalink
upgrade to zio 2.0.0 (#927)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamgfraser authored Jun 24, 2022
1 parent 7091af7 commit 8eb2d6b
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ addCommandAlias(
";lawsNative/test;experimentalLawsNative/test" // `test` currently executes only compilation, see `nativeSettings` in `BuildHelper`
)

val zioVersion = "2.0.0-RC6"
val zioVersion = "2.0.0"

lazy val root = project
.in(file("."))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ object AssociativeEither {
implicit def ExitAssociativeEither[E]: AssociativeEither[({ type lambda[+a] = Exit[E, a] })#lambda] =
new AssociativeEither[({ type lambda[+a] = Exit[E, a] })#lambda] {
def either[A, B](fa: => Exit[E, A], fb: => Exit[E, B]): Exit[E, Either[A, B]] =
fa.map(Left(_)) match {
case Exit.Failure(_) => fb.map(Right(_))
fa.mapExit(Left(_)) match {
case Exit.Failure(_) => fb.mapExit(Right(_))
case res => res
}
}
Expand All @@ -101,7 +101,7 @@ object AssociativeEither {
new AssociativeEither[({ type lambda[+e] = Failure[Exit[e, A]] })#lambda] {
def either[EA, EB](fa: => Failure[Exit[EA, A]], fb: => Failure[Exit[EB, A]]): Failure[Exit[Either[EA, EB], A]] =
Failure.wrap {
Failure.unwrap(fa).mapError(Left(_)) *> Failure.unwrap(fb).mapError(Right(_))
Failure.unwrap(fa).mapErrorExit(Left(_)) *> Failure.unwrap(fb).mapErrorExit(Right(_))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ object AssociativeFlatten {
new IdentityFlatten[({ type lambda[+a] = Exit[E, a] })#lambda] {
def any: Exit[E, Any] = Exit.unit

def flatten[A](ffa: Exit[E, Exit[E, A]]): Exit[E, A] = ffa.flatten
def flatten[A](ffa: Exit[E, Exit[E, A]]): Exit[E, A] = ffa.flattenExit
}

/**
Expand Down
2 changes: 1 addition & 1 deletion core/shared/src/main/scala/zio/prelude/Bicovariant.scala
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ object Bicovariant {
implicit val ExitBicovariant: Bicovariant[Exit] =
new Bicovariant[Exit] {
override def bimap[A, E, AA, EE](f: A => AA, g: E => EE): Exit[A, E] => Exit[AA, EE] =
_.mapBoth(f, g)
_.mapBothExit(f, g)
}
}

Expand Down
2 changes: 1 addition & 1 deletion core/shared/src/main/scala/zio/prelude/Invariant.scala
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ object Invariant extends LowPriorityInvariantImplicits with InvariantVersionSpec
implicit def ExitCovariant[E]: Covariant[({ type lambda[+a] = Exit[E, a] })#lambda] =
new Covariant[({ type lambda[+a] = Exit[E, a] })#lambda] {
override def map[A, B](f: A => B): Exit[E, A] => Exit[E, B] = { exit =>
exit.map(f)
exit.mapExit(f)
}
}

Expand Down
13 changes: 7 additions & 6 deletions core/shared/src/main/scala/zio/prelude/fx/ZPure.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package zio.prelude.fx

import com.github.ghik.silencer.silent
import zio.internal.{Stack, StackBool}
import zio.internal.Stack
import zio.prelude._
import zio.{CanFail, Chunk, ChunkBuilder, NonEmptyChunk, Tag, ZEnvironment, ZIO}

Expand Down Expand Up @@ -567,7 +567,7 @@ sealed trait ZPure[+W, -S1, +S2, -R, +E, +A] { self =>
val stack: Stack[Any => ZPure[Any, Any, Any, Any, Any, Any]] = Stack()
val environments: Stack[ZEnvironment[Any]] = Stack()
val logs: Stack[ChunkBuilder[Any]] = Stack(ChunkBuilder.make())
val clearLogOnError: StackBool = StackBool()
var clearLogOnError = false
var s0: Any = s
var a: Any = null
var failed = false
Expand Down Expand Up @@ -637,7 +637,7 @@ sealed trait ZPure[+W, -S1, +S2, -R, +E, +A] { self =>
zPure.value,
(cause: Cause[Any]) =>
ZPure.suspend(Succeed({
val clear = clearLogOnError.peekOrElse(false)
val clear = clearLogOnError
val builder = logs.pop()
if (!clear) logs.peek() ++= builder.result()
})) *> ZPure.set(state) *> zPure.failure(cause),
Expand Down Expand Up @@ -677,14 +677,15 @@ sealed trait ZPure[+W, -S1, +S2, -R, +E, +A] { self =>
val zPure = curZPure.asInstanceOf[Flag[Any, Any, Any, Any, Any, Any]]
zPure.flag match {
case FlagType.ClearLogOnError =>
clearLogOnError.push(zPure.value)
val oldValue = clearLogOnError
clearLogOnError = zPure.value
curZPure = zPure.continue.bimap(
e => {
if (zPure.value) logs.peek().clear()
clearLogOnError.popOrElse(false)
clearLogOnError = oldValue
e
},
a => { clearLogOnError.popOrElse(false); a }
a => { clearLogOnError = oldValue; a }
)
}
}
Expand Down

0 comments on commit 8eb2d6b

Please sign in to comment.