Tue Aug 18 11:40:50 EDT 2015


Basically, this is a two step process.

What I want is

  Comp (Code (Int -> t))

What I get is

  Int -> Comp (Code t)

Let's abstract it properly, move the plumbing into compUnfold.

The current, incorrectly typed version looks like:

compSignal :: Flatten t => Signal Comp t -> State -> Term
compSignal = compSC . compUnfold

compUnfold (Signal i u) = unfold i u $ undefined

instance MakeVar (Code t) => Unfold Comp (Code t) where
  unfold init update = \_ -> do
    si <- makeVar
    codeState Prev si init
    (so, o) <- update si
    codeState Next si so
    return o

EDIT: Solved by adding an Unfold constructor in Term, which indicates
the context is inside a time-unfold, where state bindings are valid
(LetS, UpdateS) and a time index is defined for input arrays