Tue Sep 6 14:34:41 CEST 2011

Commuting monad & state observe

The point is to make the projection from state to list of observed
primitive states only structural, meaning that just the original
structural product is lost, but not the primitive contents.  I.e. with
pi primtive state components we have:

  (s0,(s1,s2)) -> [p0,p1,p2]
  ()           -> []

This way there is no worry that any projection in the evaluation of
the monad (for construction of binding environment) looses any


  1. Why keep original product in composition?  -> It serves a
     purpose: easier to take apart.

  2. Is it necessary to have the following path-independence?

        m (s,o) -> (e,s,o) -> (e,[p],o)

        m (s,o) -> m ([p],o) -> (e,s,o)

  3. Phantom types get stripped also, so the typed primitives and
     compiled-to primitives cannot be the same.
     Actually, the notion of state primitive does not need to be know
     in the SigOpM primitive functions.  I.e. one could lift a SigOpM
     over a complex number class.

  4. Is it possible to treat i and o the same, or does their structure
     always needs to be known?  Same argument about primitivies.
     Projection to primitive probably needs to be more geneneral than
     only state.


  * Focus on structural projection to list of primitives.  

  * As long as the primitive base type has dynamic type annotation,
    order of operations should not be important: project from
    structured to unstructured type at any convenient moment.