-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 a trait LeftFoldable[F[_]] such that Foldable[F[_]] <: LeftFoldable[F[_]] #1339
Comments
Can you give an example of a structure that would satisfy |
For my purposes, it was more about just being interested in the left-associative fold, and not wanting to have to implement the right-associative method. If one can be implemented from the other, maybe the better answer is to provide a pair of sub-classes, where only one implementation is required and the companion has a default implementation in terms of that, with whatever efficiency impact there may be. |
Ah, that makes a lot of sense. I believe what you're looking for - default implementations of redundant typeclass methods - is covered by #992, which is currently attached to the 1.0.0 milestone. Scalaz 8 should also have it out of the box when it's released, as of scalaz/scalaz#1226. Haskell has a similar mechanism for declaring that e.g., Foldable requires at least |
Actually another angle (and not mutually exclusive) would be to provide factory methods that generate concrete instantiations, based on either a left-associative definition or right-. However, that may be more an algebird style of solution than in cats. |
It seems useful (at least, to me) to encode a notion of objects that support left-associative folding but not right-associative:
Foldable[F[_]] <: LeftFoldable[F[_]]
Likely also:
Foldable[F[_]] <: RightFoldable[F[_]]
The text was updated successfully, but these errors were encountered: