go-functional
go-functional copied to clipboard
Add CollectErr consumer and related helpers
Please provide a brief description of the change.
A common form of iteratoring with an iter.Seq will be pairs of values where the right side is an error (for exampling iterating over lines in an io.Reader. CollectErr is a helper that will collect the left values from the iterator and the right error values will be joined into a single error.
Which issue does this change relate to?
None.
Contribution checklist.
- [X] I have read and understood the CONTRIBUTING guidelines
- [X] All commits in my PR conform to the commit hygiene section
- [X] I have added relevant tests
- [X] I have not added any dependencies
Additional context
I've also added some helper functions to extend the power of this change. op.Apply{Left/Right} are to be used with Map2 in order to apply a function to only left or right values. I'm considering Filter{Left/Right} also.