[Haskell] Types of when and unless in Control.Monad

Iavor Diatchki iavor.diatchki at gmail.com
Wed Jun 6 00:12:02 CEST 2012


Hello,

-1 for me too, for the reasons already discussed in the thread (i.e.,
because it makes it easy to accidentally ignore potentially important
results).  I think that gains in readability from this generalization are
at best questionable.

-Iavor




On Tue, Jun 5, 2012 at 2:07 PM, Andres Löh <andres at well-typed.com> 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. Also, whether a space leak with mapM
> arises or not typically doesn't depend on whether you use its result
> or not. It's the other way round: if you run mapM on a huge list but
> aren't interested in the results, then you should use mapM_ instead.
> So the problem here is accidentally producing a (large) result rather
> than accidentally ignoring it.
>
> Cheers,
>  Andres
>
> --
> Andres Löh, Haskell Consultant
> Well-Typed LLP, http://www.well-typed.com
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://www.haskell.org/mailman/listinfo/libraries
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20120605/9fedc233/attachment.htm>


More information about the Libraries mailing list