
On 06.06.12 12:13 AM, Henning Thielemann wrote:
On Tue, 5 Jun 2012, Andres Löh wrote:
Btw. the mapM memory leak can be easily and accidentally resurrected by writing
when_ b (mapM f xs)
with
f :: a -> m () when_ :: Bool -> m a -> m ()
I don't understand the whole mapM analogy (yet). I don't need when_ to get into trouble with using mapM.
If I write
when b (mapM f xs)
with
f :: a -> m () when :: Bool -> m () -> m ()
then GHC will say something like: Cannot match [()] (result of 'mapM') with () (argument of 'when').
Well, but nothing in the type system prevents you from writing mapM f xs >> cont or do mapM f xs cont so you are not warned of a space leak in the common situations anyway, but you are responsible yourself. I don't know why 'when' should be any different than '>>'. Cheers, Andreas -- Andreas Abel <>< Du bist der geliebte Mensch. Theoretical Computer Science, University of Munich Oettingenstr. 67, D-80538 Munich, GERMANY andreas.abel@ifi.lmu.de http://www2.tcs.ifi.lmu.de/~abel/