Created
December 20, 2019 14:27
-
-
Save qingwei91/37d2c4e32abc383bb6cf97e41f8c7dc7 to your computer and use it in GitHub Desktop.
Use IO to wrap each loop
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
| import cats.effect._ | |
| def retryIfNone(innerIO: IO[Option[Int]]): IO[Int] = { | |
| innerIO.flatMap { | |
| case Some(i) => | |
| println("something") // used to show some output when testing | |
| IO.pure(i) | |
| case None => | |
| println("nothing") // used to show some output when testing | |
| retryIfNone(innerIO) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment