Getting Started with λÆS

Installation

The library is available on Maven Central. Add the following dependencies to your build.sbt:

libraryDependencies ++= Seq(
  "in.rcard.yaes" %% "yaes-core" % "0.5.0",
  "in.rcard.yaes" %% "yaes-data" % "0.5.0"  // Optional: for Flow and data structures
)

The library is only available for Scala 3 and is currently in an experimental stage. The API is subject to change.

Modules

Your First Effect

Let’s start with a simple example using the Random and Raise effects:

import in.rcard.yaes.Random.*
import in.rcard.yaes.Raise.*

def flipCoin(using Random, Raise[String]): String = {
  val result = Random.nextBoolean
  if (result) "Heads" else "Tails"
}

Running Effects

To execute the effectful computation, use handlers:

import in.rcard.yaes.Random.*
import in.rcard.yaes.Raise.*

val result: String = Raise.run { 
  Random.run { 
    flipCoin
  }
}

Key Concepts

Effects vs Side Effects

Deferred Execution

Calling effectful functions doesn’t immediately execute them. Instead, they return a value representing a computation that can be run later.

Handlers

Handlers are the tools that execute deferred effects. They can be composed and applied selectively.

Next Steps