Having an Empty constructor prevents the root node from being unpacked. So for example, shoving six elements into the tail in one go will allocate six whole new root nodes on the heap, even though five of those are immediately garbage. The usual fix is just to make the empty value a zero-length slice of a zero-length array. To enhance sharing, there can be a single NOINLINE top-level empty sequence.
Having an
Empty
constructor prevents the root node from being unpacked. So for example, shoving six elements into the tail in one go will allocate six whole new root nodes on the heap, even though five of those are immediately garbage. The usual fix is just to make the empty value a zero-length slice of a zero-length array. To enhance sharing, there can be a singleNOINLINE
top-level empty sequence.