
to be clear: I definitely have strict evaluation now. It works. And it
helped me to fix my bug (it's fixed now).
But I think that to actually get strict evaluation I needed BOTH bang
patterns AND deep seq, at that same time... Which seems strange to me, I
would think that either would suffice.
emmanuel
On Tue, Dec 25, 2012 at 1:17 PM, Emmanuel Touzery
Hello,
laziness just gave me some headache now. Because some of my code was evaluated much later, well first the memory use exploded but also I got an error which was really difficult to understand because it manifested much later than I would intuitively expect (when I read the record field, not when I wrote it...).
Now, if nothing else for space usage needs, I need to make this strict.
At first I tried bang patterns on my record:
{-# LANGUAGE BangPatterns #-}
data TvShow = TvShow { channel :: Channel, title :: !T.Text, startTime :: !T.Text, summary :: !T.Text } deriving (Eq, Show)
That did not help.
Then I tried deepseq:
instance NFData TvShow
return $!! result
That did not help.
And here's the catch: doing BOTH helps... I mean I think I'll check it again because I find it hard to believe but right now it really seems it behaves like that...
Is that possible? That I need to combine BOTH deepseq and bang patterns to actually get my code to evaluate when filling in the data? Or am I going crazy?
Thank you!
Emmanuel