Skip to content
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

Merged
merged 2 commits into from
Oct 26, 2016
Merged

Conversation

travisbrown
Copy link
Contributor

This is a draft of a FAQ entry about the (newly mandatory) stack safety of tailRecM, as suggested by @kailuowang in #1412.

@travisbrown travisbrown mentioned this pull request Oct 25, 2016
13 tasks
@non
Copy link
Contributor

non commented Oct 25, 2016

Looks good to me. Thanks @travisbrown! 👍

@kailuowang
Copy link
Contributor

Looks great! Thanks! @travisbrown 👍


```tut:fail:silent
def tailRecM[A, B](a: A)(f: A => F[Either[A, B]]): F[B]
}
Copy link
Collaborator

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.

Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Collaborator

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 ?

@travisbrown
Copy link
Contributor Author

Thanks, @peterneyens, @adelbertc—fixed now.

@adelbertc
Copy link
Contributor

👍 thanks!

@codecov-io
Copy link

codecov-io commented Oct 25, 2016

Current coverage is 92.20% (diff: 100%)

Merging #1427 into master will not change coverage

@@             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          

Powered by Codecov. Last update 93a4d6a...575bc77

@travisbrown
Copy link
Contributor Author

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.

@travisbrown travisbrown merged commit d45967a into typelevel:master Oct 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants