Last active
July 24, 2021 18:10
-
-
Save kossal/3cdf15dd5d5d512cad89e9c2800b01d8 to your computer and use it in GitHub Desktop.
ZIO greeting app
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
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