Created
July 24, 2021 21:42
-
-
Save kossal/fffd7c40972051eddf7def4d2fd053f9 to your computer and use it in GitHub Desktop.
Greeting ZIO app with for
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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