Skip to content

Consider adding Data.Sequence.{splitAtR, takeR, dropR} #159

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

Open
JLimperg opened this issue Jun 22, 2015 · 6 comments
Open

Consider adding Data.Sequence.{splitAtR, takeR, dropR} #159

JLimperg opened this issue Jun 22, 2015 · 6 comments

Comments

@JLimperg
Copy link

I was recently surprised by the lack of splitAtR, takeR and dropR in Data.Sequence when takeWhileR and dropWhileR are available. Taking this question to Stack Overflow, a simple implementation of splitAtR in terms of splitAt and length was suggested by SO user chi. Would you consider adding these functions?

@treeowl
Copy link
Contributor

treeowl commented Jun 22, 2015

In general, the way to get things added to containers is to start by sending a proposal to [email protected]. The only real exception I know of is if you're looking to add an obvious instance declaration.

@foxik
Copy link
Contributor

foxik commented Jun 22, 2015

Personally I am not sure whether these functions would benefit the API. Sure, I understand the consistency argument. On the other side, having a lot of functions can be a bit overwhelming and complicated for the users to find what they like.

As the suggested functions just "reverse" the index given to them (to index from right instead of left), I would personally not include in the API (it is trivial to implement them by yourself, and I do not think they are used very frequently). Note that that is not the case with takeWhileR and dropWhileR, which cannot be implemented efficiently using takeR and dropR.

@JLimperg
Copy link
Author

@treeowl: If I understand the process correctly, a proposal should start out with an issue on the tracker; this is that.

@foxik: For what it's worth, I did not see the solution, though that may be indicative of my problem solving skills more than the API quality. ;) Seeing that Data.Sequence generally provides functions for both ends of the sequence, I assumed that takeR and dropR only admitted an inefficient implementation and were therefore not present (though I was suspicious enough to ask the SO question).

If you don't consider these functions worth adding, would you accept a doc patch that points out how to implement them?

@foxik
Copy link
Contributor

foxik commented Jun 22, 2015

@JLimperg It is my personal view that the functions you are suggesting are not worth adding -- but others may feel differently. Therefore do not hesitate to ask on libraries@haskell (or somewhere else) and if more people would like to have the functions in the API, I will gladly add them.

As for the doc patch, that we can surely add.

@treeowl
Copy link
Contributor

treeowl commented Apr 25, 2016

It's my personal view that these functions are worth adding, but I agree with @foxik that the matter should be raised on the libraries list.

@sjakobi sjakobi added feature-request Seq needs-libraries-proposal A proposal needs to be discussed on the libraries mailing list labels Jul 15, 2020
@meooow25 meooow25 added low-hanging-fruit and removed needs-libraries-proposal A proposal needs to be discussed on the libraries mailing list labels Mar 29, 2025
@meooow25
Copy link
Contributor

This was requested again in #884, and treeowl and I are both in favor of adding the variants. A PR would be welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants