Replies: 1 comment
-
This is a language change. It does not need to be forwarded here. Closing as duplicate of original post |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Forwarded from fsharp/fslang-suggestions#1276
Today we can map list to array, iterate array, etc
Would be awesome to treat tuple the same way
I understand it might contain different types in a tuple, so perhaps we can invent a tuple that only contains the same type for example (int * int), and we add these nice functionality for us to do (5,10) |> Tuple.Map (fun number -> number.ToString())
For people who walk this path after us, they can create specializations for tuple of primitive types to be struct, optimize etc
Tuple tends to contain a couple elements as they had to be written out in code by hand usually and it's a syntax sugar to everyday f# users so might as well make it more useful and cost nothing to use
But for now adding new functions to tuple and making the language treat tuple with the same types and different types differently, is the topic (that means (5,5) and (5,"5") is treated as two different types by the language, allowing tuple mapping functions be able to be used on the former)
We should also add a method called normalize, (5,"5") |> Tuple.Normalize (fun a,b -> a, int(b)) which infers the types contained in tuple and allow us to convert it to a tuple that only contains 1 type
Beta Was this translation helpful? Give feedback.
All reactions