[Haskell-cafe] Desugaring ArrowLoop notation
fa-ml at ariis.it
Fri Jan 27 01:32:36 UTC 2017
I was reading Stephen's Arrow Tutorial , where (among other
things), a way to compute the running mean of a stream of integers
using circular programming (ArrowLoop) is shown:
mean5 :: Fractional a => Circuit a a
mean5 = proc value -> do
(lastTot, lastN) <- delay (0,0) -< (tot, n)
let (tot, n) = (lastTot + value, lastN + 1)
let mean = tot / n
returnA -< mean
To understand the example better I tried to convert the `rec do` notation
to plain loop/(>>>) one (i.e. without syntactic sugar), but failed.
So I ask: what's the sour version of `mean5`?
More information about the Haskell-Cafe