You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I guess the motivation was that inside the flatMap the .value might not blow the stack and if the F[_] is lazy it would possibly be safe.
The change makes us always evaluate the Eval[F[B]], but it is safe.
The motivation of the map2Eval is for Monads like Try/Either that a failure on the left avoids evaluating the right. This change will evaluate the Eval in those cases and no longer short circuit.
Maybe to mitigate this we want to make sure any shortcircuiting Monads in cats override map2Eval so we don't regress on cases like Try, Future, Either. Maybe others.
A middle ground could be to override StackSafeMonad to use the .value on the idea that the flatMap is always lazy in a StackSafeMonad. That may work or may have other issues that I don't see.
Maybe to mitigate this we want to make sure any shortcircuiting Monads in cats override map2Eval so we don't regress on cases like Try, Future, Either. Maybe others.
Yes, good call. I think that would a correct direction to go. We don't know and can't guess whether current FlatMap instance is for a short-circuiting Monad or not. The goal for generic methods is to be as safe as possible (I believe so). The concrete implementation though does know whether their Monad can short-circuit or not. So, it is more likely their responsibility to optimize for short-circuiting cases.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #4858.