marcinzh/turbolift
Algebraic Effects for Scala 3
{ "createdAt": "2019-04-14T18:00:05Z", "defaultBranch": "master", "description": "Algebraic Effects for Scala 3", "fullName": "marcinzh/turbolift", "homepage": "https://marcinzh.github.io/turbolift/", "language": "Scala", "name": "turbolift", "pushedAt": "2026-03-19T14:06:09Z", "stargazersCount": 82, "topics": [ "algebraic-effects", "functional-programming", "scala" ], "updatedAt": "2026-03-19T14:24:01Z", "url": "https://github.com/marcinzh/turbolift"}Turbolift: Algebraic Effects for Scala 3.
Section titled “Turbolift: Algebraic Effects for Scala 3.”Visit the microsite for description.
See also:
| Project | Description |
|---|---|
| DaaE | Demo: a debugger implemented as an effect |
| Spot | Cats-Effect instances for Turbolift’s IO effect |
| Enterprise | HTTP server implemented using Turbolift’s effects |
| Beam | Streams implemented with Turbolift’s effects |
| Effect Zoo | Microbenchmark suite for several effect systems, including Turbolift |
Example
Section titled “Example”Runnable with scala-cli.
[!IMPORTANT] Turbolift requires Java 11 or newer.
//> using scala "3.3.7"//> using dep "io.github.marcinzh::turbolift-core:0.126.0"import turbolift.!!import turbolift.effects.{ReaderEffect, StateEffect, ErrorEffect}
@main def main = // 👉 Definitions of custom effect instances: case object MyReader extends ReaderEffect[Int] case object MyState extends StateEffect[Int] case object MyError extends ErrorEffect[String]
val program = for a <- MyState.get b <- MyReader.ask c <- if b != 0 then !!.pure(a / b) else MyError.raise(s"Tried to divide $a by zero") _ <- MyState.put(c) yield ()
val result = program .handleWith(MyState.handler(100)) .handleWith(MyReader.handler(3)) .handleWith(MyError.handler) .run
println(result) // Right(((),33))
Same, but with [bindless]!(modules/bindless) syntax extension.
Similar to async/await, or Rust’s ? operator.
//> using scala "3.3.7"//> using dep "io.github.marcinzh::turbolift-core:0.126.0"//> using dep "io.github.marcinzh::turbolift-bindless:0.126.0"import turbolift.!!import turbolift.effects.{ReaderEffect, StateEffect, ErrorEffect}import turbolift.bindless._
@main def main = // 👉 Definitions of custom effect instances: case object MyReader extends ReaderEffect[Int] case object MyState extends StateEffect[Int] case object MyError extends ErrorEffect[String]
val program = `do`: val a = State.get.! val b = Reader.ask.! val c = if b != 0 then a / b else Error.raise(s"Tried to divide $a by zero").! State.put(c).!
val result = program .handleWith(State.handler(100)) .handleWith(Reader.handler(3)) .handleWith(Error.handler) .run
println(result) // Right(((),33))
See also [examples]!(modules/examples/src/main/scala/examples/) folder. Runnable with sbt:
sbt examples/runUsage in SBT
Section titled “Usage in SBT”libraryDependencies += "io.github.marcinzh" %% "turbolift-core" % "0.126.0"Optionally, for the [bindless]!(modules/bindless) syntax extension:
libraryDependencies += "io.github.marcinzh" %% "turbolift-bindless" % "0.126.0"