Wed Aug 5 00:45:25 EDT 2015

The other monad

Use a `copy` operator?
Lift every operation with Applicative?

Define an extra Monad that performs a join?

The Applicative will create things like:

(Sig m (m a))

And we want

m (Sig m a)

return . joinSig?

joinSig :: (Sig m (m o)) -> (Sig m o)
joinSig (Sig f0 f) = (Sig f0 f') where
  f' s = do
    (s', mo) <- f s
    o <- mo -- (*)
    return (s', o)

(*) This ensures the computation is sequenced.  So return . joinSig is

So how to take a sig and make it shared?  Applying the lifted
identity?  That doesn't sound right...

Nonsense.. time for bed.

EDIT: Basically, joinSig is enough for operations on signals.  The
problem is in using things like:

let x = primitive_signal
mul x x  

x <- copy primitive_signal
mul x x

It seems the copy is essential, as in Comp it introduces a variable
for the output of the signal, and it is that variable that is then fed
into mul.

Call copy 'fanout' ?

Or just wrap all systems in a copy?

Hmm..  Try it with some examples.