
per.gustafsson:
Haskell gurus,
We have made a proposal to extend the Erlang `binary' data type from being a sequence of bytes (a byte stream) to being a sequence of bits (a bitstream) with the ability to do pattern matching at the bit level.
Our experience in writing efficient (and beautiful) Haskell programs is close to (if not below) zero. Also, perhaps our mind might be suffering from severe case of strictness and might be completely unable to `think lazily'. So, we request your help in noticing obvious NO-NOs and stupid mistakes that we might have made. We even welcome completely different Haskell programs provided they adhere to the constraint mentioned above -- no mutation.
Ok, I rewrote the drop3 program to use packed, unboxed arrays as the OCaml version does, instead of lazy boxed lists. It now runs in 3.5s on my linux box, which is around which is around what the OCaml version does. $ ghc B.hs $ ./a.out testdata.drop3 3.617 $ cmp testdata.drop3.haskell testdata.drop3.out Comparing lazy list IO against packed array IO is a bit silly, so I suggest you use the same buffer types in your Haskell code as you do in the OCaml code. Otherwise the comparisons aren't very meaningful. The problem is not so much laziness, as you suggest, but that you're using a completely unsuitable data type: lists, instead of (packed) strings. You can most likely just translate your other OCaml programs into Haskell as I have done here, which would be a good basis for a reasonable comparison. You may also find the Haskell performance resource useful, http://www.haskell.org/haskellwiki/Performance Cheers, Don