Skip to content
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

Revise groupAllBy to just use an Ordering function #191

Merged
merged 10 commits into from
Mar 18, 2022

Conversation

milesfrain
Copy link
Contributor

@milesfrain milesfrain commented Jan 13, 2021

Description of the change

Fixes #189

Also modified the tests and examples to demonstrate which grouping functions involve sorting.

One of the commits reverts demoing the convenience of the :|| infix operator proposed in #190. We can redo those changes if that operator is accepted.


Checklist:

  • Added the change to the changelog's "Unreleased" section with a reference to this PR (e.g. "- Made a change (#0000)")
  • Linked any existing issues or proposals that this pull request should close
  • Updated or added relevant documentation
  • Added a test for the contribution (if applicable)

@hdgarrood
Copy link
Contributor

Can you please include only the changes for groupAllBy in this PR, and not the other documentation changes?

log "groupAllBy should group equal elements into lists based on an equivalence relation"
assert $ groupAllBy (\x y -> odd x && odd y) (l [1, 3, 2, 4, 3, 3]) == l [NEL.singleton 1, NEL.singleton 2, NEL.NonEmptyList (3 :| l [3, 3]), NEL.singleton 4]
log "groupAllBy should sort then group equal elements into lists based on a comparison function"
assert $ groupAllBy (compare `on` (_ `div` 10)) (l [32, 31, 21, 22, 11, 33]) == l [nel 11 [], nel 21 [22], nel 32 [31, 33]]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A test case like this is necessary to demonstrate the degree of ordering preserved.
I wanted this to be consistent with the docs and then I wanted to make sure this was easily relatable to the other group* tests and examples.

Comment on lines 587 to 577
-- | For example,
-- |
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's pretty obvious that what follows is an example, so figured it would be better to remove that line to make the pursuit results more compact.

-- |
-- | For example,
-- | Group equal, consecutive elements of a list into lists, using the provided
-- | equivalence function to determine equality.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the approved phrasing for the nubBy changes, so wanted to keep things consistent here too.

@milesfrain
Copy link
Contributor Author

milesfrain commented Jan 13, 2021

I can thin down this PR so it only touches groupAllBy and then make a follow-up PR with the docs consistency changes. Ideally, those could be merged back-to-back.

@hdgarrood
Copy link
Contributor

Yes please, these two things should ideally be reviewed separately.

test/Test/Data/List.purs Outdated Show resolved Hide resolved
@milesfrain
Copy link
Contributor Author

milesfrain commented Jun 29, 2021

Resolved latest merge conflicts. Ready for another review.

Comment on lines -31 to +32
- Added `groupAllBy` (#182, #191)
- Added `groupAllBy` (#182)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prematurely added this PR to the changelog in #195. I was hoping this PR would have been included in the batch of breaking changes, so the release history would show groupAllBy as being added correctly the first time.

In hindsight, it would have been better to add the #191 tag here in this PR. That could have achieved the same result (assuming it got merged before the release), and would have avoided recent confusion where rebasing to master eliminated all changelog edits for this PR.

@milesfrain
Copy link
Contributor Author

@JordanMartinez Please add "breaking change" label.

@JordanMartinez JordanMartinez added the type: breaking change A change that requires a major version bump. label Jun 30, 2021
@JordanMartinez
Copy link
Contributor

@milesfrain Done thanks!

@JordanMartinez JordanMartinez added the purs-0.15 A reminder to address this issue or merge this PR before we release PureScript v0.15.0 label Dec 1, 2021
@thomashoneyman thomashoneyman merged commit 7498594 into purescript:master Mar 18, 2022
@milesfrain milesfrain deleted the group-all-by-ordering branch March 25, 2022 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
purs-0.15 A reminder to address this issue or merge this PR before we release PureScript v0.15.0 type: breaking change A change that requires a major version bump.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Revise groupAllBy to just use an Ordering function
4 participants