Efficient Monadic Streams
Konferensbidrag (offentliggjort, men ej förlagsutgivet), 2015
Functional stream representations allow for a high-level, compositional way of programming digital signal processing algorithms. However, some algorithms, such as filters, cannot be efficiently implemented using purely functional techniques, due to excessive copying of data. We present a monadic representation of streams which introduces the ability to use mutation for efficiency when implementing algorithms. Still, our representation enjoys many of the benefits of purely functional streams, such as a functional API and fusion. Our representation enables further optimizations: we show how to remove duplicate loop variables, and how to keep buffers entirely in references. Our measurements show that the new monadic representation consistently outperforms the functional representation by at least a factor of four when evaluated in the context of the Feldspar embedded DSL.