Tue Aug 2 09:13:37 CEST 2011

Conclusion: Num can be sequential

The big revelation of last couple of days is that it is possible to
compile a Num class expression into a dataflow graph (SSA expression)
by using the CPS monad.

My earlier attempt had a fundamental misconception; it represented
numbers as data structures.  The fix is to implement numbers as a
state-continuation monad, i.e. as functions.  Here the Num operations
don't need to "merge" data structures; they simply compose functions
using bind from the monad.

Still there is the problem of sharing, which seems to necessitate the
use of a special purpose `let' expression.  This is a bit subtle and
has to do with running a CPS computation multiple times vs. using its
result.  See previous posts.