STG Program to invoke rule 17?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

STG Program to invoke rule 17?

Siddharth Bhat
I'm reading the original STG paper and implementing it along the way. (Raw link to paper:  https://www.dcc.fc.up.pt/~pbv/aulas/linguagens/peytonjones92implementing.pdf)
I'm not able to figure out how to invoke rule 17 at all. This rule is to update a function call which calls another function. I've tried creating examples, but all of them wind up invoking the constructor update rule.

╰─$ cat stg-programs/updatable-fn-calls.stg
define nu = {} \n {x, y, w, z} -> x {};
define main = {} \n {} -> let
                            x = {} \n {} -> One {};
                            y = {} \n {} -> Two {};
                            // closure to update
                            update = {x, y} \u {} -> nu {x, y, y, y};
                            // have something in argument stack
                            kickstart = {update} \n {a, b} -> update {};
                            // make sure this is never evaluated
                            bottom = {} \n {} -> bottom {}
                         in case (kickstart {bottom, bottom}) of
                                 One {} -> Done {};

This was a program I tried, hoping that the "kickstart" function would ensure that there is something on the argument stack, so that when "nu" is entered, the rule would trigger. However, in my toy STG implementation here (simplexhc link) (Raw: https://github.com/bollu/simplexhc), the rule is not triggered. You can run it with:
$ stack build && stack exec simplexhc -- stg-programs/updatable-fn-calls.stg

I believe I have either misunderstood the rule or mis-implemented it. So if someone could point me to a reference of how to trigger the rule, I'd be very thankful.
I'd like to have some intuition on the rule and "why it works".

Cheers,
~ Siddharth
--
Sending this from my phone, please excuse any typos!

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: STG Program to invoke rule 17?

Kei Davis


On 06/06/2017 06:00 AM, [hidden email] wrote:
> [Haskell-cafe] STG Program to invoke rule 17?

This isn't a proper answer to your question, but I found the "fast
curry" paper to be more useful for understanding STG
http://community.haskell.org/~simonmar/papers/evalapplyjfp06.pdf

--
Kei Davis
Applied Computer Science Group CCS-7, Mail Stop B287
Los Alamos National Laboratory
Los Alamos, NM 87545, U.S.A.
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Loading...