As an exercise in Haskell, I\'m trying to implement heapsort. The heap is usually implemented as an array in imperative languages, but this would be hugely inefficient in purely
You could also use the ST monad, which allows you to write imperative code but expose a purely functional interface safely.
ST