
On Tue, Mar 13, 2001 at 09:40:09 +0200, Matthias Fischmann wrote:
Yes, that does not look very nice but it should work. In a private response, I was also pointed out the alternative solution of using case together with `seq` to trigger evaluation, which looked like the default way to me (what else is seq for?):
suppose sth. like: foo someRecord = do ... foo someRecord{ field = field' } this may lead to quite some memory allocation (I had this case once, IIRC), and eventually it can be reduced by using `seq`: foo someRecord = do ... let r = someRecord{ field = field' } r `seq` foo r
| case monstrousDS `seq` True of True -> hPutStr stderr "ok."
*hmm* this just evaluates to WHNF, no?
From hugs:
Prelude> case (42,error "foo") `seq` True of True -> putStrLn "yow" yow
I first tried to wrap this in a `force' function, thereby proving that I still haven't grasped the concept entirely. (-:
forceEval x = if x == x then x else x but this *still* needs a decent equality on `x'... 8->
But maybe it is possible to make a primitive of this in the same way as has been done with assert?
This would definitely help to e.g. keep exceptions inside `catch'-blocks sometimes (of course at the expense of not being able to use infinite data structures at the same time there)... Cheers, Michael -- /~\ ASCII ribbon | "I would rather spend 10 hours reading someone else's \ / campaign | source code than 10 minutes listening to Musak waiting X against | for technical support which isn't." / \ HTML mail | -- Dr. Greg Wettstein, Roger Maris Cancer Center