Skip to content

Instantly share code, notes, and snippets.

@rssh
Created April 13, 2021 17:49
Show Gist options
  • Save rssh/5a9ad11889b405955d61ae530d1dd313 to your computer and use it in GitHub Desktop.
Save rssh/5a9ad11889b405955d61ae530d1dd313 to your computer and use it in GitHub Desktop.
example of using ZIO with dotty-cps-async
val program = asyncRIO[TLogging] {
val ctr = await(Ref.make(0))
while {
val v = await(ctr.get)
await(TLog.logMsg(v.toString))
if v % 3 == 0 then
await(TLog.logMsg("fizz"))
if v % 5 == 0 then
await(TLog.logMsg("buzz"))
await(ctr.update(_ + 1))
v < 10
} do ()
await(TLog.lastRecords(20))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment