Sun Jul 19 23:23:43 EDT 2015

I'm looking at it the wrong way

I'm solving the wrong problem.

What's the point?  Create a Haskell model and a representation of a
program form the same program text.

There is no reason to ever have to use explicit (s,i) -> (s,o)
functions in Haskell.  It is enough to stick with (S i) -> (S o) where
S is an abstract representation of a stream.

State can be (and should be?) invisible.

Only in the generated code is it relevant, and as such it can probably
just be hidden, or "erased early".

The code will be well typed, and can be "retyped" easily.

How can you represent all possible programs in a single type?  It is
possible using the trick described above.

The value is that by not erasing the type, it can be re-interpreted.

So it might be valueable to have a map:

generator :: language -> program