How do I make a Scalaz ZIO lazy?
问题 I have a heavy side-effecting function (think database call) that I want to use as a lazy value, so that it gets called only on first use (and not at all if never used). How do I do this with ZIO? If my program looks like this, the function gets called only once (but even the result is not used at all): import scalaz.zio.IO import scalaz.zio.console._ object Main extends scalaz.zio.App { def longRunningDbAction: IO[Nothing, Integer] = for { _ <- putStrLn("Calling the database now") } yield 42