funfix icon indicating copy to clipboard operation
funfix copied to clipboard

[Feature Request] Add a datastructure for Tuple

Open puneetar opened this issue 6 years ago • 5 comments

#It would be great to have a data structure for Tuple

Tuple <A, B>{
  _1 : A
  _2 : B
}

// functions
function fold()
function bimap()

puneetar avatar Apr 17 '18 18:04 puneetar

Why do you think this?

I feel a tuple type innecesary in JavaScript because arrays can do the work. Tuples are interesing in typed languages where you cant mix types in arrays without lost their types, but this does not happen in js.

ErunamoJAZZ avatar Apr 27 '18 20:04 ErunamoJAZZ

True, I want to use the tuple with flow typing.

puneetar avatar Apr 28 '18 14:04 puneetar

But in the way you suggested this, _1 and _2 have the same type, maybe you are thinking in some like Tuple<A, B> instead?

I am not using flow or ts right now, so I really don't see why this could be interesting :/

ErunamoJAZZ avatar Apr 28 '18 16:04 ErunamoJAZZ

🤦 corrected it.

True, it may not be interesting right now, but it is helpful when you want to return 2 types and creating a class with 2 objects is an overkill.

Take a look at https://github.com/fantasyland/fantasy-tuples, it is perfect but just don't have typescript or flow types. Therefore, though it would be perfect for funfix : Functional Programming Library for JavaScript, TypeScript and Flow

puneetar avatar Apr 28 '18 18:04 puneetar

Will the authors be willing to include tuples if I work on it and create a PR ?

puneetar avatar Jul 26 '18 18:07 puneetar