Clojure's transducers in Scala.
Inspired by Clojure's implementation (obviously) and this Haskell implementation and theory.
Documentation can be found here.
Transducers are applicable objects that transform reducers. If you've ever worked with folding or reduction in a functional language, a reducer is simply a representation of the reduction function used in those functions.
A reducer has three effective signatures:
identity: R
)completion: R => R
)stepL: R => A => R
,
stepR: A => R => R
)A transducer adds a layer of transformation onto these reducers, and can be both stateful or stateless. They are also composeable using simple function composition.
This library aims to provide interfaces for creating immutable and mutable state transducers and the ability to use them.