-
-
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
Some clean up for Free (and friends). #1085
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4d548a9
Some clean up for Free (and friends).
erik-stripe b7afcb1
Add tests for new Free methods.
erik-stripe 3eca17f
Add a short-circuiting implementation of foldLeftM
ceedubs f7567d8
Merge pull request #1 from ceedubs/short-circuiting-foldLeftM
non dc375e5
Merge remote-tracking branch 'upstream/master' into topic/free-additi…
erik-stripe 861361c
Fix merge conflict.
erik-stripe 36e9471
Merge remote-tracking branch 'origin/topic/free-additions-cleanup' in…
erik-stripe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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.
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.
Did I miss it, or does this method not use the
G.tailRecM
method at all?Also, it seems like there is double trampolining (once via
Free
and once viaEval
inF.foldRight
)? I wonder if a more direct implementation (using eitherFree
orEval
, but not both) is possible.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.
@TomasMikula as the author of this code, I'll be the first to say that it is a bit bizarre.
G.tailRecM
should be being called by therunTailRec
call on theFree
structure.Eval
makes an appearance due to thefoldRight
type signature, but really we are just usingfoldRight
because of its laziness, andunsafeFoldLeftM
is calling.value
on theEval
, so we don't actually get anyEval
trampolining here. It's effectively like we are using a scalaz-stylefoldRight
that takes a byname parameter, since we aren't taking advantageEval
's trampolining.If you can figure out a way to provide a more direct implementation, I'd definitely be interested. I think that this has to be done in terms of
foldRight
if we want laziness, though, which meansEval
will definitely be in play. You may be able to useMonadRec
andfoldRight
withoutFree
, and if so that'd be great - as it stands I'm kind of convinced that we should moveFree
(the monad but not the other free structures) back into core for this sort of thing.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.
One other note: it really isn't obvious to me that this implementation should be stack safe, but the tests kind of prove that it is
¯\_(ツ)_/¯
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.
somehow I completely missed that
.runTailRec
at the end 😊