[Haskell-cafe] qsort

Peter Verswyvelen bugfact at gmail.com
Sat Aug 15 04:09:28 EDT 2009

I was reading the introduction at
where the typical Haskell version of qsort is given

qsort [] = []
qsort (x:xs) = qsort
(< x) xs) ++<http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:.>
[x] ++<http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:.>qsort
) xs

which is then compared to the inplace C version, showing off how much
shorter the Haskell version is.

However, the page also has a link to a "semi-direct" translation of the C
version, which then brings the user to all kinds of confusing threads and
texts, like

*"**Unfortunately none of the above "real" quicksorts seems to compile as
given, when copy/pasted into ghci. Can someone fix? The "parallel" quicksort
gave error "unknown package concurrent" when I ran make in
quicksort/gransim. Has anyone got a functioning "real" quicksort that works
on copy/paste? The program below is working very very slowly. It's probably
slowsort... :o)"*
Furthermore the inplace versions of qsort in Haskell are IMO less readable
than the C version.

I'm not sure but if I would be a beginner I might get confused by this.

It is often claimed that compiler technology will make it possible to
compile high level code into efficient low level code that is almost as
efficient as the C or asm routines. How does this apply to qsort today?

Peter Verswyvelen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090815/a53b661c/attachment.html

More information about the Haskell-Cafe mailing list