Hello,

thank you for the discussion on eager evaluation.

For solving my memory problem I finally used the 

        x == x `seq` return x

approach because it is easier to derive Eq classes automatically than to
write some sequentialisation functions.

(First I defined

class Eager a where
    eager :: a -> a

and some instances:

instance Eager Int where
    eager i = i `seq` i

instance Eager Char where
    eager c = c `seq` c

instance Eager a => Eager [a] where
    eager [] = []
    eager (x : xs) = eager x `seq` eager xs `seq` (x : xs)

instance Eager a => Eager (a, a) where
    eager (x, y) = eager x `seq` eager y `seq` (x, y)

(Is this correct?)

But I stopped here because its quite a lot of work to give all the
instances for the types involved. Furthermore, I was not sure how to cope
with record types.)

Michael







Reply via email to