Proposal: Add modify' to Control.Monad.State.Strict

Niklas Hambüchen mail at nh2.me
Mon Apr 28 20:36:02 UTC 2014


Code like

   flip execState 0 (forever $ modify (+1))

leaks memory as hell, and gets fixed by using

  x <- get
  put $! x + 1

I propose the addition of modify' to Control.Monad.State.Strict.

This seems useful for the strict state monad and is consistent with
similar functions in base (such as modifyIORef').

Discussion period: 2 weeks.


More information about the Libraries mailing list