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

Add Countable[T] #167

Closed
johnynek opened this issue Jun 19, 2013 · 4 comments
Closed

Add Countable[T] #167

johnynek opened this issue Jun 19, 2013 · 4 comments
Milestone

Comments

@johnynek
Copy link
Collaborator

Not totally sure about this:

Think it is:

trait Countable[T] {
  def next(t: T): Option[T]
  def prev(t: T): Option[T]
}

an infinite T might never return None, but Int, Long, Double etc instances would.

@johnynek
Copy link
Collaborator Author

Haskell has one of these go from Option[T] to Option[T] which I assume is so you can start from nothing. I think that is conflating lowerbounded with countable and I don't like it, but maybe I'm wrong here.

@arkajit
Copy link

arkajit commented Jun 27, 2013

What's the use case for this? To implement bi-directional iteration over T? For basic numeric types, won't an appropriate Range get you the same effect?

@sritchie
Copy link
Collaborator

"for basic numeric types", exactly, but what about more complex types? Think Week.

@johnynek
Copy link
Collaborator Author

Or BatchID, or (Int, Int), or...

We want to express algorithms once that only demand the weakest properties of their inputs.

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

3 participants