-
-
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
Remove RecursiveTailRecM, move stack safety checks into MonadLaws - f… #1370
Conversation
b1f8878
to
9faa88f
Compare
9faa88f
to
02c7e3e
Compare
Hm it seems it fails for |
@@ -138,7 +132,7 @@ sealed abstract class Free[S[_], A] extends Product with Serializable { | |||
* enough, this will work | |||
*/ | |||
final def foldMapUnsafe[M[_]](f: FunctionK[S, M])(implicit M: Monad[M]): M[A] = | |||
foldMap[M](f)(M, RecursiveTailRecM.create) | |||
foldMap[M](f) |
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 foldMapUnsafe
be deprecated then?
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.
this should just be removed if you ask me. I doubt anyone is using it and removing RecursiveTailRecM
is at least as big of an issue.
Should the unsafe |
@adelbertc in the worst-case you can make the test platform-specific using I know ScalaTest supports a style of asynchronous testing that works with futures in JS, so you could also look into that. |
@non I looked into the async testing support in ScalaTest but it seems like due to how our tests are constructed it's not really compatible? My understanding is the new async stuff lets you give ScalaTest a |
Looks like the build failed because some of our @adelbertc Understood. It seems like it would be a big undertaking to try to change our test code to be able to take advantage of that feature. What you have here seems good for now. |
bb51f3c
to
bb927c7
Compare
Current coverage is 91.72% (diff: 100%)@@ master #1370 diff @@
==========================================
Files 239 238 -1
Lines 3611 3600 -11
Methods 3484 3474 -10
Messages 0 0
Branches 126 125 -1
==========================================
- Hits 3312 3302 -10
+ Misses 299 298 -1
Partials 0 0
|
Of course, I'm +1. I think asking for stack safety (given it seems always achievable) is fine. I do know of a Monad that was not made stack safe (yet?) Enumeratee, I think it was in iteratee-io (@travisbrown). I have not looked too hard at making it stack safe. One issue is that the worst case may require trampolines and some library authors might not like that. I wonder if we could devise a trampoline-like approach that only impacts tailRecM and does not hurt the performance of flatMap. |
@johnynek The more I think of it the more convinced I am I am curious about that data type you talked about in @travisbrown 's iteratee lib though. @kailuowang @non Do I have a 👍 from either of you? :D |
@johnynek @adelbertc |
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.
This comment mentioning the defaultTailRecM impl should be removed
https://github.com/typelevel/cats/blob/master/core/src/main/scala/cats/FlatMap.scala#L94-L108
👍 |
…ixes #1278 and fixes #1283
cc @johnynek @non