Sat Feb 13 09:25:21 CET 2010

Let's start again

What is the problem?  I miss intuition diving into state+cps.
Additionally, I'm still not sure whethere it's a good idea to leave
the expression realm.

Isn't it possible to turn the problem upside down, i.e. when I write
TERM1 + TERM2, this constructs a composition of two functions,
i.e. make the arithmetic expressions do nothing but _serializing_ the
computation, and feed any extra environment in later.


  - create a Num class that can partially evaluate (PE) a numeric
    algorithm expressed in straight haskell.

So we're not really after staging, but after PE; that's the starting
point.  Maybe later we can add annotation that help the PE.

What is then the problem to solve?  It is memoization: how to know if
two expressions are equal, either resulting from:

  - explicit `let'

  - equivalence (CSE)

Goals: don't loose sharing introduced by `let', and if possible allow
arbitrary equivalences to lift out common expressions.

So, what this does is to take an underlying term type and an
equivalence of terms, and construct a wrapper around it to keep track
of expression sharing.

So there are the following modules:

  1) ai.hs / ainum.hs : term type and partial evaluation

  2) nodes.hs : environment threading ( ANF/SSA conversion + CSE )

The important part is that both are separate.  Let's stick to ai.hs
for 1) and focus on building nodes.hs on top of an abstract term type.