Tue Oct 16 11:07:25 CEST 2018

State machine

I'm stuck.  I have no behavioral language to express this, can't
quickly build one, so will need to continue with fully explicit
"functional" updates.

_ = do
  (carry,dec') <- carry dec cnt
  [state',cnt] = switch state [
    (wait, do
        ifs i [wait,0] [count,half]),
    (count, do
        ifs carry [idle,0] [count,dec']),
    (idle, do
        ifs en [wait,0] [idle,0])]

So why does this happen?  Many state machines do a lot of waiting,
which doesn't change the state.  You want this to be easily expressed.

Really, though, am I just looking for excuses? It works, it's just not
easy to use when there is a lot of state.  But maybe proper factoring
can solve that problem independently?  I.e. define sub-machines, and
provide control lines.

( Still, it itches.  There must be some simple transform where
variables are moved into dynamic context. )