Wed Oct 19 11:54:35 EDT 2011
Abstracting foldable code
I just tried some more aimless poking around, making both the function
body and the result more abstract, but I'm loosing the point of the
What I want to do really is to have a representation of a "bound" fold
in both a functional and list form. The reason I want this is that it
might not be trivial to express manually (separately) when there are
In short, I have TML which has no support for recursion, and I can map
it to 2 representations:
TMLf -> Code -> SSA (Code is an intermediate form, the real result is SSA).
TMLf -> Value
Now TMLf can be used to represent a code body which can be folded. I
would like to keep this fold operation abstract, so I can have the
same expression (a body + fold) be evaluated to a Haskell function on
(nested) lists, or some output machine code.
This requires two objects:
- function rep (i.e. Sys or TermLS)
- IO rep
These could be combined in multiple ways. I.e. the function body
could be translated to a representation of just the body, but it might
be simpler to do it all together by evaluating the body over a
specific IO rep.
The real flexibility then comes when these loops can be nested.
Conclusion: I don't just need a loop body representation, I also need
a way to represent nested loop bodies.
Let's let this sink in a bit..
- key are folds of (s,i) -> (s,o) bodies. Loops with state.
- I can't represent nesting yet