[Haskell-cafe] using mutable data structures in pure functions

Johan Tibell johan.tibell at gmail.com
Thu Mar 15 01:56:20 CET 2012

On Wed, Mar 14, 2012 at 5:50 PM, wren ng thornton <wren at freegeek.org> wrote:
> Do note, however, that in certain cases the ST approach can be much slower
> than the obvious immutable approach (i.e., the State monad--- especially
> when implemented directly via argument passing, rather than using the
> monadic interface). I have some closed-source code where that assumption bit
> me; the ST code was over 4x slower.

An additional reason is that runST often allocates a closure (as it's
marked NOINLINE) and thus using it e.g. in a tight loop can increase

-- Johan

More information about the Haskell-Cafe mailing list