The order if bindings generated by GHC

I use STG-bindings generated by GHC during CoreToSTG phase. What is the order of this bindings is it random or does it correspond to original source code or does it reflect the dependency structure of the program? If I define the following in my program: data Numeral = Zero | Succ Numeral zero = Zero one = Succ zero ... ten = Succ nine the order of zero .. ten definition will remain the same, but the special Zero binding will be generated and added to the end of the bindings list. But Zero is used by binding of one (strangely enough) so order doesn't reflect dependency. What is the order of bindings? If I need the order reflecting dependency, should I sort it myself by SRT tables or there is an easier way? -- vir http://vir.comtv.ru/

You probably want -ddump-simpl to print Core Yes, the bindings should be in dependency order. They certainly seem to be for me Simon Foo.hs data Numeral = Zero | Succ Numeral zero = Zero one = Succ zero ten = Succ one ghc -c -ddump-stg -ddump-simpl Foo.hs ==================== Tidy Core ==================== Foo.zero :: Foo.Numeral [GlobalId] [NoCafRefs] Foo.zero = Foo.Zero Foo.one :: Foo.Numeral [GlobalId] [NoCafRefs] Foo.one = Foo.Succ Foo.Zero Foo.ten :: Foo.Numeral [GlobalId] [NoCafRefs] Foo.ten = Foo.Succ Foo.one ==================== Tidy Core Rules ==================== ==================== STG syntax: ==================== Foo.zero = NO_CCS Foo.Zero! []; SRT(Foo.zero): [] Foo.one = NO_CCS Foo.Succ! [Foo.Zero]; SRT(Foo.one): [] Foo.ten = NO_CCS Foo.Succ! [Foo.one]; SRT(Foo.ten): [] Foo.Zero = NO_CCS Foo.Zero! []; SRT(Foo.Zero): [] Foo.Succ = \r [eta_s68] Foo.Succ [eta_s68]; SRT(Foo.Succ): [] bash-3.1$ | -----Original Message----- | From: glasgow-haskell-users-bounces@haskell.org [mailto:glasgow-haskell-users-bounces@haskell.org] On Behalf Of | Victor Nazarov | Sent: 19 November 2007 15:09 | To: glasgow-haskell-users@haskell.org | Subject: The order if bindings generated by GHC | | I use STG-bindings generated by GHC during CoreToSTG phase. What is | the order of this bindings is it random or does it correspond to | original source code or does it reflect the dependency structure of | the program? | If I define the following in my program: | | data Numeral = Zero | Succ Numeral | | zero = Zero | one = Succ zero | ... | ten = Succ nine | | the order of zero .. ten definition will remain the same, but the | special Zero binding will be generated and added to the end of the | bindings list. But Zero is used by binding of one (strangely enough) | so order doesn't reflect dependency. What is the order of bindings? If | I need the order reflecting dependency, should I sort it myself by SRT | tables or there is an easier way? | | -- | vir | http://vir.comtv.ru/ | _______________________________________________ | Glasgow-haskell-users mailing list | Glasgow-haskell-users@haskell.org | http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Simon Peyton-Jones writes:
Yes, the bindings should be in dependency order. They certainly seem to be for me
Simon
I always - naively - thought that it is a non-problem. How many times have I written stuff like that:... ping = 0 : pong pong = 1 : ping It seems that I don't understand the question of Victor Nazarov, nor the answer of SPJ... Jerzy Karczmarczuk

On Nov 19, 2007 9:39 PM,
I always - naively - thought that it is a non-problem. How many times have I written stuff like that:...
ping = 0 : pong pong = 1 : ping
It seems that I don't understand the question of Victor Nazarov, nor the answer of SPJ...
This is the question about GHC internals, not programing style or smth. -- vir http://vir.comtv.ru/

I wrote about binding order:
I always - naively - thought that it is a non-problem. How many times have I written stuff like that:...
ping = 0 : pong pong = 1 : ping
It seems that I don't understand the question of Victor Nazarov, nor the answer of SPJ...
This is the question about GHC internals, not programing style or smth.
Perhaps you will not believe me, but I realized that myself... The question is: what about ordering in the presence of cyclic dependencies, not about style or smth. Jerzy Karczmarczuk
participants (3)
-
jerzy.karczmarczuk@info.unicaen.fr
-
Simon Peyton-Jones
-
Victor Nazarov