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

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.

+1
On Mon, Apr 28, 2014 at 10:36 PM, Niklas Hambüchen
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. _______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries

+1. I've defined this practically every time I've used the strict state monad. -- Darius Jahandarie (Mobile)
On Apr 28, 2014, at 3:36 PM, Niklas Hambüchen
wrote: 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. _______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries

On Apr 28, 2014, at 5:02 PM, Darius Jahandarie
wrote: +1. I've defined this practically every time I've used the strict state monad.
-- Darius Jahandarie (Mobile)
Likewise, +1 Anthony
On Apr 28, 2014, at 3:36 PM, Niklas Hambüchen
wrote: 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. _______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries
Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 +1. Seems like a very logical candidate for a strict version. - -- Alexander alexander@plaimi.net https://secure.plaimi.net/~alexander -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iF4EAREIAAYFAlNexoAACgkQRtClrXBQc7V0eAEAsVq1VFGdLozMWTunn3WJtR6w rZw6iyGJW90WBzLLL6YBAKUZxzUt+bne44gLsHiFLKc5eECryDFc49CW33nxjYOD =O/R1 -----END PGP SIGNATURE-----

+1 from me. I've had to reinvent this a few times myself.
On Mon, Apr 28, 2014 at 5:22 PM, Alexander Berntsen
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256
+1.
Seems like a very logical candidate for a strict version.
- -- Alexander alexander@plaimi.net https://secure.plaimi.net/~alexander -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iF4EAREIAAYFAlNexoAACgkQRtClrXBQc7V0eAEAsVq1VFGdLozMWTunn3WJtR6w rZw6iyGJW90WBzLLL6YBAKUZxzUt+bne44gLsHiFLKc5eECryDFc49CW33nxjYOD =O/R1 -----END PGP SIGNATURE----- _______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries

+1
* Niklas Hambüchen
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. _______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries

On Mon, Apr 28, 2014 at 09:36:02PM +0100, Niklas Hambüchen wrote:
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.
transformers-0.4 has modify' for both state monads -- it's useful for both.
participants (10)
-
Alexander Berntsen
-
Anthony Cowley
-
Darius Jahandarie
-
Edward Kmett
-
Johan Tibell
-
John Wiegley
-
Niklas Hambüchen
-
Roman Cheplyaka
-
Ross Paterson
-
Vincent Hanquez