Skip to content

Instantly share code, notes, and snippets.

@kossal
Last active July 24, 2021 18:10
Show Gist options
  • Save kossal/3cdf15dd5d5d512cad89e9c2800b01d8 to your computer and use it in GitHub Desktop.
Save kossal/3cdf15dd5d5d512cad89e9c2800b01d8 to your computer and use it in GitHub Desktop.
ZIO greeting app
package app
import zio._
import zio.console._
import java.io.IOException
object App extends zio.App {
def respond(name: String): ZIO[Console, IOException, Unit] =
putStrLn(s"Hello $name! It's nice to finally meet you")
val salute: ZIO[Console, IOException, Unit] = putStrLn("Hello! What's your name?")
val getUserName: ZIO[Console, IOException, String] = salute.flatMap(_ => getStrLn)
val action: ZIO[Console, IOException, Unit] = getUserName.flatMap(respond)
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