In scope-passing style: use a Movable b instead of Ur b#473
Merged
Conversation
Member
Author
|
I think I've got all the places where I could do this. @Qqwy did you have other places is mind that I might have missed? |
Functions of the form ```haskell f :: (A %1 -> Ur b) %1 -> Ur b ``` are now of the form ```haskell f :: Movable b => (A %1 -> b) %1 -> b ``` The new type is strictly more general. Technically this seems to involve some extra allocations here and there. I expect it to be negligible (we don't want to call too many scoped functions anyway). The extra allocation is interesting, in that it's not always strictly necessary: when returning an `Int`, I don't need to produce an `Ur Int` to make sure that I've actually forced everything, just returning the forced `Int` would do the trick. Yet we use an `Ur Int` to communicate that we've indeed done the job (in some cases the optimiser can actually remove the extra allocation, but not in every case as far as I can tell). Maybe there are cheaper way to tell the compiler that we've, in fact, moved the value. But that's a question for the future. See #468 for the initial discussion.
4fffe65 to
582cfda
Compare
Contributor
|
@aspiwack Thanks for tagging me! I think you've caught them all. 🚀 |
Member
Author
|
Let me merge then. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Functions of the form
are now of the form
The new type is strictly more general. Technically this seems to involve some extra allocations here and there. I expect it to be negligible (we don't want to call too many scoped functions anyway).
The extra allocation is interesting, in that it's not always strictly necessary: when returning an
Int, I don't need to produce anUr Intto make sure that I've actually forced everything, just returning the forcedIntwould do the trick. Yet we use anUr Intto communicate that we've indeed done the job (in some cases the optimiser can actually remove the extra allocation, but not in every case as far as I can tell). Maybe there are cheaper way to tell the compiler that we've, in fact, moved the value. But that's a question for the future.See #468 for the initial discussion.