funfix
funfix copied to clipboard
[Feature Request] Add a datastructure for Tuple
#It would be great to have a data structure for Tuple
Tuple <A, B>{
_1 : A
_2 : B
}
// functions
function fold()
function bimap()
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.
True, I want to use the tuple with flow typing.
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 :/
🤦 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
Will the authors be willing to include tuples if I work on it and create a PR ?