-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add some FlatMap loops useful for State and Effects #2249
Conversation
* for polling type operations on State (or RNG) Monads, or in effect | ||
* monads. | ||
*/ | ||
def untilDefined(implicit F: FlatMap[F]): F[A] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't name this the same as untilDefinedM
because it is slightly different. OptionT[F, Option[A]]
should still have access to untilDefinedM. This can possibly be removed since it adds little over optt.value.untilDefinedM
Codecov Report
@@ Coverage Diff @@
## master #2249 +/- ##
==========================================
+ Coverage 94.95% 94.96% +<.01%
==========================================
Files 333 333
Lines 5788 5797 +9
Branches 221 221
==========================================
+ Hits 5496 5505 +9
Misses 292 292
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems pretty useful to me 👍
case Left(big) => big should === (1001) | ||
case Right((_, _)) => fail("unreachable code due to Nothing, but scalac won't let us match on it") | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick. The current implementation looks stack safe, but shall we still add a stack safety test for future guard rail?
@kailuowang look good now? |
Thanks for adding the test. @johnynek |
Three cases I have wanted:
Gen[Option[A]] => Gen[A]
IO[Unit]
then repeating that forever.S => IO[S]
that each call updates the state and repeat forever.This has to be done with syntax backwards compatibility hacks, but we can repair that at cats 2.0