Skip to content

Commit

Permalink
Changed order of handled effects in Layer.run
Browse files Browse the repository at this point in the history
  • Loading branch information
jiveshungerford committed Dec 13, 2023
1 parent a8e09e4 commit e9b3e87
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 25 deletions.
4 changes: 2 additions & 2 deletions kyo-core/shared/src/main/scala/kyo/aborts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ object aborts {
def layer[Se](handle: E => Nothing > Se): Layer[Aborts[E], Se] =
new Layer[Aborts[E], Se] {
override def run[T, S](
effect: T > (S with Aborts[E])
effect: T > (Aborts[E] with S)
)(
implicit flat: Flat[T > (S with Aborts[E])]
implicit flat: Flat[T > (Aborts[E] with S)]
): T > (S with Se) =
self.run[T, S](effect)(flat).map {
case Left(err) => handle(err)
Expand Down
8 changes: 4 additions & 4 deletions kyo-core/shared/src/main/scala/kyo/envs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ object envs {

def layer[Sd](construct: E > Sd): Layer[Envs[E], Sd] =
new Layer[Envs[E], Sd] {
override def run[T, S](effect: T > (S with Envs[E]))(implicit
fl: Flat[T > (S with Envs[E])]
): T > (S with Sd) =
construct.map(e => self.run[T, S](e)(effect: T > (Envs[E] with S)))
override def run[T, S](effect: T > (Envs[E] with S))(implicit
fl: Flat[T > (Envs[E] with S)]
): T > (Sd with S) =
construct.map(e => self.run[T, S](e)(effect))
}
}

Expand Down
30 changes: 15 additions & 15 deletions kyo-core/shared/src/main/scala/kyo/layers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ package kyo
object layers {

trait Layer[In, Out] { self =>
def run[T, S](effect: T > (S with In))(implicit fl: Flat[T > (S with In)]): T > (S with Out)
def run[T, S](effect: T > (In with S))(implicit fl: Flat[T > (In with S)]): T > (S with Out)

final def add[Out1, In1](other: Layer[In1, Out1]): Layer[In with In1, Out with Out1] =
new Layer[In with In1, Out with Out1] {
override def run[T, S](
effect: T > (S with In with In1)
effect: T > (In with In1 with S)
)(
implicit fl: Flat[T > (S with In with In1)]
implicit fl: Flat[T > (In with In1 with S)]
): T > (S with Out with Out1) = {
val selfRun: T > (S with In1 with Out) =
self.run[T, S with In1](effect: T > (S with In1 with In))
val otherRun: T > (S with Out with Out1) =
val selfRun: T > (In1 with Out with S) =
self.run[T, S with In1](effect: T > (In1 with In with S))
val otherRun: T > (Out with Out1 with S) =
other.run[T, S with Out](selfRun)(Flat.unsafe.unchecked)
otherRun
}
Expand Down Expand Up @@ -46,8 +46,8 @@ object layers {
layer2: Layer[In2 with Shared, Out2]
): Layer[In1, Out1 with Out2] =
new Layer[In1, Out1 with Out2] {
override def run[T, S](effect: T > (S with In1))(implicit
fl: Flat[T > (S with In1)]
override def run[T, S](effect: T > (In1 with S))(implicit
fl: Flat[T > (In1 with S)]
): T > (S with Out2 with Out1) = {
val handled1: T > (S with Out1 with Shared) = layer1.run[T, S](effect)
val handled2: T > (S with Out2 with Out1) =
Expand All @@ -69,8 +69,8 @@ object layers {
layer2: Layer[In2 with Shared, Out2]
): Layer[In1, Out2] =
new Layer[In1, Out2] {
override def run[T, S](effect: T > (S with In1))(implicit
fl: Flat[T > (S with In1)]
override def run[T, S](effect: T > (In1 with S))(implicit
fl: Flat[T > (In1 with S)]
): T > (S with Out2) = {
val handled1: T > (S with Shared) = layer1.run[T, S](effect)
val handled2: T > (S with Out2) =
Expand All @@ -90,8 +90,8 @@ object layers {
layer2: Layer[Shared, Out2]
): Layer[In1, Out1 with Out2] =
new Layer[In1, Out1 with Out2] {
override def run[T, S](effect: T > (S with In1))(implicit
fl: Flat[T > (S with In1)]
override def run[T, S](effect: T > (In1 with S))(implicit
fl: Flat[T > (In1 with S)]
): T > (S with Out1 with Out2) = {
val handled1: T > (S with Out1 with Shared) = layer1.run[T, S](effect)
val handled2: T > (S with Out1 with Out2) =
Expand All @@ -115,10 +115,10 @@ object layers {
layer2: Layer[Out, Out2]
): Layer[In1, Any with Out2] =
new Layer[In1, Any with Out2] {
override def run[T, S](effect: T > (S with In1))(implicit
fl: Flat[T > (S with In1)]
override def run[T, S](effect: T > (In1 with S))(implicit
fl: Flat[T > (In1 with S)]
): T > (S with Out2) = {
val handled1: T > (S with Out) = layer1.run[T, S](effect)
val handled1: T > (Out with S) = layer1.run[T, S](effect)
val handled2: T > (S with Out2) =
layer2.run[T, S](handled1)(Flat.unsafe.unchecked)
handled2
Expand Down
4 changes: 2 additions & 2 deletions kyo-core/shared/src/main/scala/kyo/options.scala
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ object options {

def layer[Se](onEmpty: => Nothing > Se): Layer[Options, Se] =
new Layer[Options, Se] {
override def run[T, S](effect: T > (S with Options))(implicit
fl: Flat[T > (S with Options)]
override def run[T, S](effect: T > (Options with S))(implicit
fl: Flat[T > (Options with S)]
): T > (S with Se) =
Options.run[T, S](effect).map {
case None => onEmpty
Expand Down
4 changes: 2 additions & 2 deletions kyo-core/shared/src/main/scala/kyo/tries.scala
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ object tries {

def layer[Se](handle: Throwable => Nothing > Se): Layer[Tries, Se] =
new Layer[Tries, Se] {
override def run[T, S](effect: T > (S with Tries))(implicit
fl: Flat[T > (S with Tries)]
override def run[T, S](effect: T > (Tries with S))(implicit
fl: Flat[T > (Tries with S)]
): T > (S with Se) =
Tries.run[T, S](effect).map {
case Failure(exception) => handle(exception)
Expand Down

0 comments on commit e9b3e87

Please sign in to comment.