-
-
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
Revert regression in Free.foldMap #713
Conversation
Before we were never hitting the Gosub case. This reveals a bug that is causing the "mapSuspension id" test to fail.
This reverts most of the changes from typelevel#702, because it appears to have caused a regression in the case of Gosub. This commit fixes the "mapSuspension id" unit test and the issue reported in typelevel#712. The stack safety test is now failing. I've commented it out for now, because an incorrectness bug seems to be worse than a stack safety issue.
Current coverage is
|
@svalaskevicius to be honest I don't understand why your change broke this. If you can find an alternative that fixes the "mapSuspension id" test and #712 but is still stack safe, that would be ideal. |
Hmm it looks I've made an error earlier in gosub suspend case and missed flatmap.. Will check later to confirm |
I think we should revert now (to remove bug) and then submit a new PR to fix the actual issue. 👍 |
had a quick look.. looks like I made it tail recursive but removing the flatMap... which is required if we want to keep the structure. so when I add it back: case Gosub(c, g) => c match {
case Suspend(s) => M.flatMap(f(s))(cc => g(cc).foldMap(f)) the recursion is not in the tail position any more and I'm not sure how to make it so.. any ideas? |
actually, does foldMap have to preseve the structure? e.g. on hackage it is maybe it would make sense to leave structure preservation to mapSuspension only? the reason being is that I don't see a way to make it both stack safe and structure preserving (using flatmap there) - that would be the ultimate solution :) |
I'm going to go ahead and merge this since |
Revert regression in Free.foldMap
This PR does a couple of things.
Firstly, it includes
Gosub
in the instances generated by theFree
Arbitrary
instance. This reveals a bug that caused the "mapSuspension id" test to fail.It also reverts most of the changes made in #702. This fixes the failing "mapSuspension id" test and #712. Unfortunately, it comes at the cost of reintroducing the stack safety issue with
Free.foldMap
, and therefore I have its stack-safety unit test ignored for now. I'm hoping that we can address this issue with a separate PR in the future.