Additional thunk for function
Simon Peyton-Jones
simonpj at microsoft.com
Fri Sep 21 09:43:42 EDT 2007
Looks wrong! You don't say what version. Not happening with 6.6.1 or the 6.8 release candidate
ghc-6.8.0.20070916 -c -ddump-stg T1.hs -O
==================== STG syntax: ====================
T1.map =
\r [f_s6M ds_s6H]
case ds_s6H of wild_s6S {
[] -> [] [];
: x_s6L xs_s6P ->
let { sat_s6R = \u [] T1.map f_s6M xs_s6P; } in
let { sat_s6O = \u [] f_s6M x_s6L; } in : [sat_s6O sat_s6R];
};
SRT(T1.map): []
bash-3.1$ ghc-6.6.1 -c -ddump-stg T1.hs -O
==================== STG syntax: ====================
T1.map =
\r [f_sem ds_seh]
case ds_seh of wild_ses {
[] -> [] [];
: x_sel xs_sep ->
let { sat_ser = \u [] T1.map f_sem xs_sep; } in
let { sat_seo = \u [] f_sem x_sel; } in : [sat_seo sat_ser];
};
SRT(T1.map): []
bash-3.1$
| -----Original Message-----
| From: glasgow-haskell-users-bounces at haskell.org [mailto:glasgow-haskell-users-bounces at haskell.org] On
| Behalf Of Victor Nazarov
| Sent: 21 September 2007 12:05
| To: glasgow-haskell-users at haskell.org
| Subject: Additional thunk for function
|
| What is the purpose for GHC to allocate a thunk for some functions?
| Why Test.map is not a function, but updatable thunk, which should
| become equal to the function just after the first call? Here is the
| details:
|
| > % ghc -c test.hs -ddump-stg
| >
| > ==================== STG syntax: ====================
| > Test.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(Test.map): []
| >
| >
| > % cat test.hs
| > module Test where
| >
| > map f [] = []
| > map f (x:xs) = f x : Test.map f xs
|
| --
| Thanks in advance
| Victor
| _______________________________________________
| Glasgow-haskell-users mailing list
| Glasgow-haskell-users at haskell.org
| http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
More information about the Glasgow-haskell-users
mailing list