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

Size or length operation on Foldable #1091

Closed
benhutchison opened this issue Jun 5, 2016 · 3 comments
Closed

Size or length operation on Foldable #1091

benhutchison opened this issue Jun 5, 2016 · 3 comments

Comments

@benhutchison
Copy link
Member

Please provide a size method, with the ordinary meaning eg:

@ Foldable[List].foldLeft(List(1, 2, 3), 0){case (count, elem) => count + 1}
res6: Int = 3

Both (a) to provide a convenient default impl for a common operation, and (b) to allow instances to define their own faster size computation.

@benhutchison
Copy link
Member Author

@ceedubs
Copy link
Contributor

ceedubs commented Jun 5, 2016

👍. I've also wondered if we should have a similar method that would be safe on infinite streams - something like "size, but stop calculating if it's over N".

afiore pushed a commit to afiore/cats that referenced this issue Jun 11, 2016
This addresses part of what is proposed in typelevel#1091.
afiore pushed a commit to afiore/cats that referenced this issue Jun 12, 2016
Override with a more performant implementation in Map, Set, and Vector using the
size method provided by the standard library.

see typelevel#1091
afiore pushed a commit to afiore/cats that referenced this issue Jun 12, 2016
Override with a more performant implementation in Map, Set, Vector and AndOne
using the size method provided by the standard library.

see typelevel#1091
afiore pushed a commit to afiore/cats that referenced this issue Jun 12, 2016
Override with a more performant implementation in Map, Set, Vector and AndOne
using the size method provided by the standard library.

see typelevel#1091
afiore pushed a commit to afiore/cats that referenced this issue Jun 12, 2016
Override with a more performant implementation in Map, Set, Vector and AndOne
using the size method provided by the standard library.

see typelevel#1091
afiore pushed a commit to afiore/cats that referenced this issue Jun 12, 2016
Override with a more performant implementation in Map, Set, Vector and AndOne
using the size method provided by the standard library.

see typelevel#1091
afiore pushed a commit to afiore/cats that referenced this issue Jun 13, 2016
Override with a more performant implementation in Map, Set, Vector and AndOne
using the size method provided by the standard library.

see typelevel#1091
afiore pushed a commit to afiore/cats that referenced this issue Jun 13, 2016
Override with a more performant implementation in Map, Set, Vector and AndOne
using the size method provided by the standard library.

see typelevel#1091
@ceedubs
Copy link
Contributor

ceedubs commented Jun 18, 2016

This was introduced in #1114.

@ceedubs ceedubs closed this as completed Jun 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants