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.
One problem I've been having in writing PureScript bindings for rot.js is getting data out of the functions that rely on callbacks. Functions like FOV.compute require the user to pass in a callback that is obligated to accumulate mutable state. While this is possible in PureScript, it's inelegant and difficult to compose.
This pull request allows the user to instead accumulate a value in a functional manner. Functions like FOV.compute now take an additional argument,
initialValue
that is passed through to thecallback as the last argument, which then returns the accumulator which is again passed to the callback, and so on. Finally, FOV.compute returns the accumulator when finished. Because these
have been tacked on to the parameters list, the change should be backwards compatible. (
undefined
will be accumulated.)Optimally, you'd be able to do this for the map and lighting interfaces as well. Unfortunately, they already return a value. The only value they return, however, is
this
. I'd personally change them to return an accumulator as well, but this might break existing code.Anyway, I understand this is a weird request and will understand if you don't like it.
PS. Sorry about deleting the trailing whitespace. I keep forgetting to turn of that "feature" of Atom.