-
-
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 FAQ entry for tailRecM #1427
Conversation
Looks good to me. Thanks @travisbrown! 👍 |
Looks great! Thanks! @travisbrown 👍 |
|
||
```tut:fail:silent | ||
def tailRecM[A, B](a: A)(f: A => F[Either[A, B]]): F[B] | ||
} |
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.
You have a rogue }
here.
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.
Removveeeeeee
|
||
The `FlatMap` type class has a `tailRecM` method with the following signature: | ||
|
||
```tut:fail:silent |
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.
Should we just use scala
modifier here since it's only failing because it's not implemented?
When you are defining a `FlatMap` instance, its `tailRecM` implementation must have two properties in order for the instance to be considered lawful. The first property is that `tailRecM` must return the same result that you would get if you recursively called `flatMap` until you got a `Right` value (assuming you had unlimited stack space—we'll get to that in a moment). In other words, it must give the same result as this implementation: | ||
|
||
```tut:silent | ||
import cats.Monad |
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 don't think we need this import, right ?
Thanks, @peterneyens, @adelbertc—fixed now. |
👍 thanks! |
Current coverage is 92.20% (diff: 100%)@@ master #1427 diff @@
==========================================
Files 242 242
Lines 3606 3606
Methods 3537 3537
Messages 0 0
Branches 69 69
==========================================
Hits 3325 3325
Misses 281 281
Partials 0 0
|
I'm going to merge this since it's green, is docs, has the votes, and is going to trigger another looooong rebuild for #1430. |
This is a draft of a FAQ entry about the (newly mandatory) stack safety of
tailRecM
, as suggested by @kailuowang in #1412.