<p>I tried to port standard binary heap into functional settings. There is an article with described idea: <a href="http://arxiv.org/pdf/1312.4666v1.pdf" rel="nofollow">A Functional Approach to Standard Binary Heaps</a>. All the source code listings in the article are in Scala. But it might be ported very easy into any other functional language.</p>
Efficient heaps in purely functional languages
<p>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 functional languages. So I've looked at binary heaps, but everything I found so far describes them from an imperative viewpoint and the algorithms presented are hard to translate to a functional setting.  How to efficiently implement a heap in a purely functional language such as Haskell?</p>

<p><em>Edit:</em> By efficient I mean it should still be in O(n*log n), but it doesn't have to beat a C program. Also, I'd like to use purely functional programming. What else would be the point of doing it in Haskell?</p>