[Haskell-cafe] Desugaring ArrowLoop notation

Francesco Ariis fa-ml at ariis.it
Fri Jan 27 01:32:36 UTC 2017

Hello cafe,

    I was reading Stephen's Arrow Tutorial [1], 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`?

[1] https://en.wikibooks.org/wiki/Haskell/Arrow_tutorial

More information about the Haskell-Cafe mailing list