Different approaches to effect systems in Scala
  • Scala 83.4%
  • Nix 16.6%
Find a file
2026-07-05 10:36:49 -07:00
.github/workflows Use a Nix derivation to build (#185) 2026-07-05 10:36:49 -07:00
project Use a Nix derivation to build (#185) 2026-07-05 10:36:49 -07:00
src/main/scala Use sbt-tpolecat to set salacOptions (#61) 2023-07-09 06:14:48 -07:00
.scalafmt.conf scalafmt: 3.11.0 -> 3.11.1 (#181) 2026-05-16 07:52:33 -07:00
build.sbt Use a Nix derivation to build (#185) 2026-07-05 10:36:49 -07:00
default.nix Use a Nix derivation to build (#185) 2026-07-05 10:36:49 -07:00
LICENSE Use a Nix derivation to build (#185) 2026-07-05 10:36:49 -07:00
README.md Initial commit 2021-09-26 07:59:46 -07:00
sbt.nix Use a Nix derivation to build (#185) 2026-07-05 10:36:49 -07:00

This is the code for a series of events about different approaches to effect systems in Scala.

For each event in the series, we:

  1. Describe an effectful program that we would like to write
  2. Discuss background and practical details about an effect system
  3. Write a toy implementation of the effect system
  4. Build and run the effectful program within the effect system

We express the following as effects:

  • Read text from stdin
  • Read environment variables
  • Write text to stdout

Our effectful programs look something like this:

val enProgram =
  for {
    _    <- write("What's your name? ")
    name <- readLn()
    _    <- write(s"Hello, ${name}!\n")
  } yield ()

val esProgram =
  for {
    _    <- write("¿Cómo te llamas? ")
    name <- readLn()
    _    <- write(s"¡Hola, ${name}!\n")
  } yield ()

val program =
  for {
    lang <- readEnv("LANG")
    _    <- if (lang.startsWith("es")) {
              esProgram
            } else {
              enProgram
            }
  } yield ()