Skip to content

Commit

Permalink
add lift method for Scala 3
Browse files Browse the repository at this point in the history
  • Loading branch information
xuwei-k committed Nov 2, 2024
1 parent c7e36cd commit c65ed13
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package org.atnos.eff

abstract class AugmentCompanion { self: Augment.type => }
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package org.atnos.eff

abstract class TranslateCompanion { self: Translate.type => }
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package org.atnos.eff

abstract class WriteCompanion { self: Write.type => }
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.atnos.eff

abstract class AugmentCompanion { self: Augment.type =>
final def lift[T[_], O[_]](f: [X] => T[X] => O[Unit]): Augment[T, O] =
new Augment[T, O] {
override def apply[Y](tx: T[Y]): O[Unit] =
f[Y](tx)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.atnos.eff

abstract class TranslateCompanion { self: Translate.type =>
final def lift[T[_], U](f: [X] => T[X] => Eff[U, X]): Translate[T, U] =
new Translate[T, U] {
override def apply[Y](kv: T[Y]): Eff[U, Y] =
f[Y](kv)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.atnos.eff

abstract class WriteCompanion { self: Write.type =>
final def lift[T[_], O](f: [X] => T[X] => O): Write[T, O] =
new Write[T, O] {
override def apply[Y](tx: T[Y]): O =
f[Y](tx)
}
}
2 changes: 2 additions & 0 deletions core/shared/src/main/scala/org/atnos/eff/Augment.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ package org.atnos.eff
trait Augment[T[_], O[_]] {
def apply[X](tx: T[X]): O[Unit]
}

object Augment extends AugmentCompanion
2 changes: 2 additions & 0 deletions core/shared/src/main/scala/org/atnos/eff/Translate.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ package org.atnos.eff
trait Translate[T[_], U] {
def apply[X](kv: T[X]): Eff[U, X]
}

object Translate extends TranslateCompanion
2 changes: 2 additions & 0 deletions core/shared/src/main/scala/org/atnos/eff/Write.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ package org.atnos.eff
trait Write[T[_], O] {
def apply[X](tx: T[X]): O
}

object Write extends WriteCompanion

0 comments on commit c65ed13

Please sign in to comment.