This is the code for a series of events about different approaches to effect systems in Scala.
For each event in the series, we:
- Describe an effectful program that we would like to write
- Discuss background and practical details about an effect system
- Write a toy implementation of the effect system
- 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 ()