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

Revert regression in Free.foldMap #713

Merged
merged 3 commits into from
Dec 7, 2015

Conversation

ceedubs
Copy link
Contributor

@ceedubs ceedubs commented Dec 4, 2015

This PR does a couple of things.

Firstly, it includes Gosub in the instances generated by the Free 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.

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.
@codecov-io
Copy link

Current coverage is 85.43%

Merging #713 into master will increase coverage by +0.01% as of d831efe

@@            master    #713   diff @@
======================================
  Files          162     162       
  Stmts         2230    2231     +1
  Branches        74      74       
  Methods          0       0       
======================================
+ Hit           1905    1906     +1
  Partial          0       0       
  Missed         325     325       

Review entire Coverage Diff as of d831efe

Powered by Codecov. Updated on successful CI builds.

@ceedubs
Copy link
Contributor Author

ceedubs commented Dec 6, 2015

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

@svalaskevicius
Copy link
Contributor

Hmm it looks I've made an error earlier in gosub suspend case and missed flatmap.. Will check later to confirm

@non
Copy link
Contributor

non commented Dec 6, 2015

I think we should revert now (to remove bug) and then submit a new PR to fix the actual issue.

👍

@svalaskevicius
Copy link
Contributor

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?

@svalaskevicius
Copy link
Contributor

@non, @ceedubs:

actually, does foldMap have to preseve the structure?

e.g. on hackage it is Map each element of the structure to a monoid, and combine the results.

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 :)

@ceedubs
Copy link
Contributor Author

ceedubs commented Dec 7, 2015

I'm going to go ahead and merge this since Free isn't really usable at the moment. I'll create a new issue for its stack safety, as @non has suggested.

ceedubs added a commit that referenced this pull request Dec 7, 2015
Revert regression in Free.foldMap
@ceedubs ceedubs merged commit 492b030 into typelevel:master Dec 7, 2015
@ceedubs ceedubs deleted the free-foldmap-bug branch December 7, 2015 12:41
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.

4 participants