Is there a reason (performance, memory, typesystem) why a Tuple is not a HList and Function is not a mapping form a HList to some value?
Performance and memory both. Tuples have O(1)
access for their elements; as typically constructed, HList
is a list, and thus has O(n)
. Also, tuples require memory for one extra object with n
references to other objects, while HList
(as a list) requires one object each (plus a next
pointer). Since the overhead of an object is about two references, this turns n+2
memory usage into 4n+2
. Not so awesome for a core language construct.
An HArray which extends AnyVal will probably have comparable performance and memory requirements as the TupleX classes. The only overhead will be the length of the array and the array index bounds checking.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With