Closed
Description
The control flow of fromDistinctAscList
for IntSet
and IntMap
is rather ... opaque. It operates using an explicit stack that seems to represent a sort of zipper for the tree being constructed. That stack is, of course, allocated on the heap, which doesn't seem ideal. The fact that the code is just a bit more complicated than I can really understand is unfortunate. My guess is that it's probably possible to shift that explicit stack onto GHC's native reduction stack, which seems likely to make the code less unreadable and more efficient.