-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tuple / Pair / Triple structures #437
Comments
Both TypeScript and Flow have support for tuple types, which are based on array values, but the type checker verifies the number and type of elements. Overall, I agree that tuple structures are handy. Materialized ( What kind of code are you writing that you want a tuple structure? |
Well, I didn't know that, and it makes sense. Points to them then. I see why it's not implemented in this library because of that, but any chance to consider it for those using the library in plain JavaScript?
I was merely talking about the former one. Can the latter one still be considered a tuple, if it's essentially a function?
I opened this issue after faking a tuple structure here and there, but this code is going to evolve soon to actually use a However, I am using an |
Sure, the functional variant is a kind of "final encoding," where if you know how you will use the tuple, you can structure your code a bit differently. Say I know I am going to use the second half of a tuple and ignore the first, I can pass Of course, you could also name the fields of your tuple and use an object/record with two properties. |
I'm also after a A In this way you could (as I need to do) convert a For now we are working around this by converting to a I note it's not currently possible/desirable to extend Immutable types #368 |
Thank you for reporting this issue and appreciate your patience. We've notified the core team for an update on this issue. We're looking for a response within the next 30 days or the issue may be closed. |
i'm also abusing |
Closing this aging issue However It would be really exciting to see someone make this happen in a PR in the future |
Disclaimer: I am using JavaScript only, so I don't know the potential specifics of TypeScript for this topic
Scala defines
Tuple
structures, fromTuple1
to...Tuple22
!Along the way,
Tuple2
andTuple3
are pretty nice, they come with extra methods (likeswap
forTuple2
. These two are so common that they respectively are aliased toPair
andTriple
(were actually, since they got deprecated in favor of a syntax we unfortunately cannot use here).Right now, if I want to make a pair, I can either use an
Array
(and therefore be mutable) or aList
(and therefore abuse the types):Isn't the second one a violation of the types?
I think it'd be nicer to have specific data structures like:
Among other things, a nice consequence of this, for those who are using JavaScript and JSDoc is that the former version has to be documented with
{List.<*>}
, while the latter one can be documented with{Pair.<string, number>}
, which is much more precise and useful documentation!Am I completely missing the point here?
The text was updated successfully, but these errors were encountered: