[Haskell-cafe] Transforming graphs with loops with Hoopl

Anakreontas anakreonmejdi at gmail.com
Sun May 1 17:59:09 UTC 2016

I am trying to implement a program transformation with Hoopl. The
transformation replaces a particular statement with variable
declarations provided that the variables have not been previously
declared. A map keeps track of declared variables where the map keys
store variable names.

The transformation works only for programs without loops. In the
program below, it should replace line
2 rec #3 INxt B37H00G
1 Global Field B37H00G
2 Global Array B37HO3R
3 rec #3 INxt B37H00G
but it doesn't.

=== Example graph ==
0 goto L4
1 L4:
2 rec #3 INxt B37H00G
3 while #3 goto L5 goto L2
4 L5:
5 Global Field VSTF01a
6 goto L4
7 L2:

I think the reason it fails is because there are two paths leading to
L4, one from the program start (line 0) and a second when the loop
repeats from line 6. In the first case the transformation produces the
substitution graph since the two variables are not in the map. In the
analysis of the second path however, the variables are in the name space so
the rewrite function returns Nothing. In the end, the second
transformation result is preserved (i.e. Nothing) and the graph is not

Do I understand correctly why the transformation fails for loops? How would 
you suggest to solve this problem?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20160501/8e73abfa/attachment.html>

More information about the Haskell-Cafe mailing list