https://kotlinlang.org logo
#arrow
Title
# arrow
k

Kev

11/11/2023, 6:53 AM
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

Alejandro Serrano.Mena

11/11/2023, 7:24 AM
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

Kev

11/11/2023, 7:47 AM
Not ideal but it’ll solve my problem. Thanks!
y

Youssef Shoaib [MOD]

11/11/2023, 12:36 PM
You can of course always Ctrl+B to go to declaration, and then copy the code and increase the parameter size.
k

Kev

11/11/2023, 4:46 PM
@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

Alejandro Serrano.Mena

11/13/2023, 1:23 PM
we actually dropped at some point from 10 to 22 because it led to issues with binary size
k

Kev

11/13/2023, 1:24 PM
That’s understandable. Please action the PR accordingly 👍
y

Youssef Shoaib [MOD]

11/13/2023, 1:26 PM
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

Kev

11/13/2023, 1:30 PM
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

Alejandro Serrano.Mena

11/13/2023, 2:56 PM
the primitives are there: you just need to nest several
zipOrAccumulate
, using Tuples (or any other type you like) as intermediate steps
k

Kev

11/13/2023, 3:04 PM
That’s what I ended up doing. Personally, I find this to be rather ugly 😞
5 Views