SandroMaglione / fpdart

Functional programming in Dart and Flutter. All the main functional programming types and patterns fully documented, tested, and with examples.
https://pub.dev/packages/fpdart
MIT License
543 stars 45 forks source link

Tuple3,4,5,6 #23

Closed erabti closed 2 years ago

erabti commented 3 years ago

What about we have Tuple3-6 or 8 as in this package https://pub.dev/packages/tuple. I can still do something hacky like Tuple2<First, Tuple2<Second, Third>> but it will be not very friendly.

SandroMaglione commented 3 years ago

Hi @erabti

I am not convinced that having and using Tuple3-8 would be a good idea. Tuple2 is usable in some usecases because it is simple and it avoids creating new classes. Tuple3-8 would be more difficult to read and manage. I think you would be better off creating a new class instead of using Tuple > 2.

Let me know what you think

SandroMaglione commented 2 years ago

Closing for now, feel free to comment below for any opinion or idea 👍

jibbers42 commented 2 years ago

Using Glados propery-based testing (https://pub.dev/packages/glados), I have a class that has more than 10 parameters (the max Glados supports directly). Due to this, I need to generate data in two steps, a Tuple10 and a Tuple4 in my case, then use both to build my class. I'm converting from dartz and the current implementation is using their Tuples.

I going to create a class, and I guess it's not a big deal, but this is the only place I'll use it... as a one-off for a test. I don't use Tuples often (more so in c# where the items can be named), but it is convenient to have them when a good use case comes up.

edit: actually, I'll create two classes I guess :)

SandroMaglione commented 2 years ago

@jibbers42 the dart team is discussing adding Records to the language. This would allow to avoid classes like Tuple.

Based on this, I think is better to wait. If/When Records come Tuple will be no more necessary anyway.