Last active
February 3, 2026 20:25
-
-
Save dacr/5ca5fb847e11d846d41bda80bd8a9933 to your computer and use it in GitHub Desktop.
ZIO simplified unsafeRun suggested by @adamfraser / published by https://github.com/dacr/code-examples-manager #4e20b965-f188-46a6-ad9d-d043edd1cd05/de8e7089f67dbbe99aeabcd7afa0b56b6f6e0a06
This file contains hidden or 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
| // summary : ZIO simplified unsafeRun suggested by @adamfraser | |
| // keywords : scala, zio, unsafeRun | |
| // publish : gist | |
| // authors : Adam Fraser | |
| // license : Apache License Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0.txt) | |
| // id : 4e20b965-f188-46a6-ad9d-d043edd1cd05 | |
| // created-on : 2022-06-25T23:48:21+02:00 | |
| // managed-by : https://github.com/dacr/code-examples-manager | |
| // run-with : scala-cli $file | |
| // --------------------- | |
| //> using scala "3.4.2" | |
| //> using dep "dev.zio::zio:2.0.13" | |
| // --------------------- | |
| import zio.* | |
| // -------------------------------------------- | |
| implicit class RunSyntax[A](io: ZIO[Any, Any, A]) { | |
| def unsafeRun: A = | |
| Unsafe.unsafe { implicit u => | |
| Runtime.default.unsafe.run(io).getOrThrowFiberFailure() | |
| } | |
| } | |
| // -------------------------------------------- | |
| val app = Console.printLine("Hello world !") | |
| app.unsafeRun |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment