Fix the `plus` operation for `FreeT` #1276

merged 2 commits into from Feb 14, 2017


None yet

2 participants


See #1275.

TomasMikula added some commits Oct 22, 2016
@TomasMikula TomasMikula Failing test case for MonadPlus[FreeT]. 9295e67
@TomasMikula TomasMikula Fix MonadPlus[FreeT].
Previous version did not work for monads such as Maybe that don't satisfy
left distributivity, i.e.

    (a <+> b) >>= f = (a >>= f) <+> (b >>= f)

Perhaps it was not clear, but I consider this ready to be merged (unlike #1275, which I created solely for the purpose of demonstrating the issue).

The key of the fix is to not stop at the first occurrence of M and perform plus on it, but keep evaluating (join-ing Ms) until the first Suspend is reached.

Let me know if you have questions/concerns.



@TomasMikula TomasMikula merged commit 82120da into scalaz:series/7.3.x Feb 14, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment