Skip to content

Instantly share code, notes, and snippets.

@kossal
Created July 24, 2021 21:42
Show Gist options
  • Save kossal/fffd7c40972051eddf7def4d2fd053f9 to your computer and use it in GitHub Desktop.
Save kossal/fffd7c40972051eddf7def4d2fd053f9 to your computer and use it in GitHub Desktop.
Greeting ZIO app with for
object App extends zio.App {
val salute: ZIO[Console, IOException, Unit] = putStrLn("Hello! What's your name?")
def respond(name: String): ZIO[Console, IOException, Unit] =
putStrLn(s"Hello $name! It's nice to finally meet you")
val action: ZIO[Console, IOException, Unit] = for {
_ <- salute
name <- getStrLn
_ <- respond(name)
} yield ()
override def run(args: List[String]): URIO[zio.ZEnv, ExitCode] = action.exitCode
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment