Can't write type-safe implementations of Tuple methods #12388
Replies: 3 comments 11 replies
-
Moving to discussions. It would be good if others could participate. |
Beta Was this translation helpful? Give feedback.
-
I believe the way to do it is using inline. The issue is that it will be |
Beta Was this translation helpful? Give feedback.
-
The problem is the So I think you're going to have much fewer troubles going with the usual way sized vectors are done in dependently-typed languages (look up how it's done in, eg, Idris, if you don't know). Especially now that #12397 is in. The main problem is that forces you to use a custom, inefficient |
Beta Was this translation helpful? Give feedback.
-
The implementations of
Tuple
methods delegate to unsaferuntime.Tuples
methods and then use a type cast (asInstanceOf
).Tuples bring generic programming to Scala 3 shows how we could safely implement the
++
(concat
) method.However, I'm at a loss to know how to safely implement other methods, such as
drop
,take
,splitAt
, to the point that I don't think it's possible (but perhaps just undocumented?).Below is a failed attempt at implementing the
drop
method. I would be happy to be shown the correct way, but for now I just think it is not possible.Compiler version
3.0.0-RC
Minimized example
Output
Beta Was this translation helpful? Give feedback.
All reactions