Rescript has only one way to access tuple elements: destructuring, this limitation prevents from using them as fixed length arrays
let ageAndName = (24, "Lil' ReScript")
// possible to get item by destructuring
let (_, name) = ageAndName
// NOT ALLOWED???
let name = ageAndName[2]
Access by index it’s type safe/sound when the compiler knows the length of the array, so index it’s limited to range {0,lenght-1} even typescript knows it
The generated tuple js is a plain array so, the only thing preventing {0,lenght-1} type safe random access is the language itself
So it would basically be just syntactic sugar, tuple length should be known at compile time as well so it seems doable.
Also, as we are on our way to get rid of the OCaml stdlib(s), we would like to get rid of fst and snd as they only support the first and second position and are of no use for larger tuples.
But at some point you should rather use a record anyways. Except maybe for special cases like React Hooks dependencies.
Destructuring is sugar. The compiler uses efficient access patterns instead of actual JS destructuring.
Tuples are not arrays. They are essentially records without labels, structs with a known layout. Random access is not possible. It’s the same restriction as not being able to use string keys for record fields.