> >> More importantly, understand how foldl' works and be ready to apply > >> the same analysis and fix to any similar function.
Hi, just a little summary of what I found, in case it might be useful to other beginners struggling with the same problems: * A good page is http://users.aber.ac.uk/ajc99/stricthaskell.html * You want to think hard about which functions you want to make strict and which are better left lazy. * Once you have it, the DeepSeq module together with some syntactic sugar permits you to annotate functions as strict easily: -- strictness annotation, to be used as -- f a x | strict a, deepStrict x = annotation -- f a x = the_true_function_body annotation = undefined strict a = seq a False deepStrict a = deepSeq a False This worked for me, nicely. In doubt, I tried both the strict and lazy versions... * Optimization often changes the behavior. * It helps to have strict versions of some common high-order functions, for example -- strict foldl, just as foldl' strictFoldl :: (a -> b -> a) -> a -> [b] -> a strictFoldl f a [] = a strictFoldl f a (x:xs) = (strictFoldl f $! f a x) xs strictFoldl1 f (x:xs) = strictFoldl f x xs * I could not find any tracing tool for ghc that would enable me to see step by step what happens. Hugs has it (look for Observe). * The heap profiling helps but I have difficulties associating the entities it shows with actual code of my program. Hope this helps, Jan -- ------------------------------------------------------------------------- Jan Kybic <[EMAIL PROTECTED]> Odyssee, INRIA, Sophia-Antipolis, France or <[EMAIL PROTECTED]>,tel. work +33 492 38 7589, fax 7845 http://www-sop.inria.fr/robotvis/personnel/Jan.Kybic/ _______________________________________________ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell