Simon PJ says:

        Did you try "seq"?  
                x `seq` y
        should evalute x to WHNF before returning y.  If x is a pair
        you may need to say

                seqPair x `seq` y

        where
                seqPair (a,b) = a `seq` b

        in order to force the components.

        Simon

There's an easier way to force structures hyperstrictly. To force x to be
evaluated to normal form before computing y, write
        (x==x) `seq` y
This depends on all the types occurring in x being Eq types, and also on 
the implementation of == being hyperstrict when its result is true. This holds
for all derived instances, and for most programmer defined ones too. After
all, if x==x holds for any non-total x, then x==y must hold for some pair of
different values x and y, which we normally try to avoid!

I sometimes write
        if x==x then y else error "I am the pope!"
but the seq form is nicer!

John Hughes

        | -----Original Message-----
        | From: Michael Marte [mailto:[EMAIL PROTECTED]]
        | 
        | 
        | 
        | I am trying to process a huge bunch of large XML files in order
        | to extract some data. For each XML file, a small summary (6 integers)
        | is created which is kept until writing a HTML page displaying the
        | results.
        | 
        | The ghc-compiled program behaves as expected: It opens one 
        | XML file after
        | the other but does not read a lot. After some 50 files, it 
        | bails out due
        | to lack of heap storage.
        | 
        | To overcome the problem, I tried to force the program to 
        | compute summaries
        | immediately after reading the corresponding XML file. I tried 
        | some eager
        | application ($!), some irrefutable pattern, and some 
        | strictness flags, but
        | I did not succeed. 

Reply via email to