[<<][meta][>>][..]
Sat Feb 13 11:05:38 CET 2010

code.hs (nodes.hs)

Flattening an expression tree is really just a fold over that tree,
where the accumulated state is the variable->term dictionary and each
term is either reused from the map or creates a new mapping.

This needs a (Term -> Term) function mapping terms to variable terms,
and an equality operation on Terms.

So, it's not necessary to have a Code datatype such that operations
can be lifted: the accumulation/flattening can be completely hidden in
process, resulting in a map of (variable, term).


So.. what is needed is a code fold, and a way to introduce new
bindings.  I.e. foldTerm and letTerm.

Or not.

I don't see it..  Let's write it in its most concrete form first.

The conversion is a tree traversal.  One part is an ANF conversion.
The second part is CSE.




[Reply][About]
[<<][meta][>>][..]