[Haskell-beginners] netwire accum delayed by one

Ertugrul Söylemez es at ertes.de
Sat Nov 3 15:09:25 CET 2012

Nathan Hüsken <nathan.huesken at posteo.de> wrote:

> With this netwire based program:
> mainWire = proc _ -> do
>   accum (+) 0 -< 1
> [...]
> I get (output):
> Right 0.0
> Right 1.0
> Right 2.0
> ...
> Should the output not start with 1.0 (and not 0.0)? The accum should
> be applied already in the first invocation, should it not?

Accum is documented to behave like a left scan, which also starts with
the initial value.  The reason is that for most applications you want
the data dependency on the previous instant instead of on the current.
Many useful FRP constructs can be (and are) expressed in terms of accum
and accumT.


Not to be or to be and (not to be or to be and (not to be or to be and
(not to be or to be and ... that is the list monad.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/beginners/attachments/20121103/5865543d/attachment.pgp>

More information about the Beginners mailing list