
On 9/21/07, Victor Nazarov
Here is some more details:
% ghc -c -ddump-stg T1.hs
==================== STG syntax: ==================== T1.map = \u [] let { map1_sdR = \r [f_sdN ds_sdI] case ds_sdI of wild_sdU { [] -> [] []; : x_sdM xs_sdQ -> let { sat_sdT = \u [] map1_sdR f_sdN xs_sdQ; } in let { sat_sdP = \u [] f_sdN x_sdM; } in : [sat_sdP sat_sdT]; }; } in map1_sdR; SRT(T1.map): []
% ghc -c -ddump-stg T1.hs -O
==================== STG syntax: ==================== T1.map = \r [f_sel ds_seg] case ds_seg of wild_ser { [] -> [] []; : x_sek xs_seo -> let { sat_seq = \u [] T1.map f_sel xs_seo; } in let { sat_sen = \u [] f_sel x_sek; } in : [sat_sen sat_seq]; }; SRT(T1.map): []
Sure, it makes sense that the extra thunk would be allocated when optimization is disabled (if you don't pass in any optimization flags like -O, it's like saying "don't do any optimization"). Don't expect GHC to generate efficient code with optimization turned off :-) Cheers, Tim -- Tim Chevalier * catamorphism.org * Often in error, never in doubt "Other than to amuse himself, why should a man pretend to know where he's going or to understand what he sees?" -- William Least Heat Moon