-
Notifications
You must be signed in to change notification settings - Fork 17
[#29] Add fromFoldableWithIndex
#30
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
Merged
JordanMartinez
merged 7 commits into
purescript:master
from
pete-murphy:pm/29/add-from-foldable-with-index
Oct 24, 2022
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0e6ade6
Add `fromFoldableWithIndex`
pete-murphy c17f1cc
Add tests for `fromFoldableWithIndex`
pete-murphy 76c0790
Fix test
pete-murphy 995093b
Document behavior on key collision
pete-murphy eacb14c
Change API for fromFoldableWithIndex functions
pete-murphy 56e9241
More general `fromFoldableWithIndexWith`
pete-murphy 489634e
Remove fromFoldableWithIndexWith
pete-murphy 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 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
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
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
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.
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.
Thoughts on adding a variant
fromFoldableWithIndex'
that assumes thek
is already aString
?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.
I'm now thinking that makes sense as the default API, based on the two use cases1 cited in the issue. They both say that
Object.fromFoldableWithIndex
would be useful specifically in the case ofFoldableWithIndex k f ~ Map String
.I think non-
String
keys would probably be the less common case, and in that case you might as well also throw in a function for combining values on conflict (instead of defaulting to overriding earlier values, which could be undesirable)basically support the (probably) common case with
fromFoldableWithIndex
and then give more granular control withfromFoldableWithIndexWith
(not sure about that naming 😄 )Footnotes
https://discord.com/channels/864614189094928394/865617619464749081/887326007105814548
https://discord.com/channels/864614189094928394/867149806178664478/1032345440248668242 ↩
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.
I think we can skip
fromFoldableWithIndexWith
because you couldmapKeys
(or equivalent) the input first.It would be more efficient to convert while doing this, but you could say the same about accepting mapping functions in
fromFoldable
s in general if we wanted to start going down that route.Uh oh!
There was an error while loading. Please reload this page.
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.
I suppose
would be the most general variation, but I don't know if that's too complicated.
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.
Didn't see your comment til after I posted mine, that makes sense to skip
fromFoldableWithIndexWith
. So would just addingmake sense?