Greetings. I’m busy using `zipOrAccumulate` to com...
# arrow
k
Greetings. I’m busy using
zipOrAccumulate
to compose smart constructors however this function as a maximum raise accumulation of 9 actions. Is there a strategy I can apply to increase the accumulation size?
a
you can nest them using a combination of tuples in the middle stages, and destructuring in the last onr:
Copy code
zipOrAccumulate(
  zipOrAccumulate(
    thing1, thing2, thing3, thing4,
    ::Tuple4
  ),
  zipOrAccumulate(
    thing5, thing6, thing7, thing8,
    ::Pair4
  )
) { (x1, x2, x3, x4), (x5, x6, x7, x8) -> ... }
1
k
Not ideal but it’ll solve my problem. Thanks!
y
You can of course always Ctrl+B to go to declaration, and then copy the code and increase the parameter size.
k
@Youssef Shoaib [MOD] some of the types are package private / internal. I’m tempted to do a PR with increased parameter size variants.
I’ve created a PR (https://github.com/arrow-kt/arrow/pull/3297) to add more parameter variants of zipOrAccumulate. I’ve noticed that the
2.0.0
milestone has reduced Tuples to Tuple9. I hope this won’t effect the span of zipOrAccumulate parameter lengths.
a
we actually dropped at some point from 10 to 22 because it led to issues with binary size
k
That’s understandable. Please action the PR accordingly 👍
y
Maybe an extra library could be provided with larger parameter sizes? Or some of the primitives for writing a
zipOrAccumulate
and the like could be made public so people can roll their own higher arity versions
k
This is a great idea. If the primitives were made publicly available, an extra library could be created to cater for such things, along with larger tuples, etc. Thoughts?
a
the primitives are there: you just need to nest several
zipOrAccumulate
, using Tuples (or any other type you like) as intermediate steps
k
That’s what I ended up doing. Personally, I find this to be rather ugly 😞