[Haskell] Space behaviour & hyperseq

Johannes Waldmann waldmann at imn.htwk-leipzig.de
Thu Jun 17 09:14:54 EDT 2004


> 1) Is there a more efficient definition of hyperseq that does not traverse
> the data structure twice? The "show" function traverses the structure once
> but I found it to be much slower.

persumably because it produces its output with (++),
or with (.) and building up lots of closures (?)

something like  class Size s where size :: s -> Int  would help.
(or a class Hash ...  -  both are nice to have anyway in a program)
(and automatic instance derivations for them would be nice as well...)

> 2) In this application the uses of lazy evaluation are rare and easily
> eliminated (zip xs [1..] and so on); is there some hidden GHC option that
> evaluates everything strictly? I realise that this would invalidate
> optimisations relying on certain laws but I just wonder how difficult this
> would be. Somebody must have given this a thought at one point.

It would also be interesting to find out what exactly
the compiler is missing when translating your program.
Ideally, it should be able to "see" that everything is strict.
-- 
-- Johannes Waldmann,  Tel/Fax: (0341) 3076 6479 / 6480 --
------ http://www.imn.htwk-leipzig.de/~waldmann/ ---------



More information about the Haskell mailing list