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

Julian Gilbey julian at d-and-j.net
Sun Apr 22 09:19:11 CEST 2012


On Sat, Apr 21, 2012 at 08:28:27PM -0500, Strake wrote:
> On 21/04/2012, Andreas Abel <andreas.abel at ifi.lmu.de> wrote:
> > to avoid silly "return ()" statements like in
> >
> >    when cond $ do
> >      monadicComputationWhoseResultIWantToDiscard
> >      return ()
> 
> (when cond ∘ void) monadicComputationWhoseResultIWantToDiscard
> or
> when cond $ () <$ monadicComputationWhoseResultIWantToDiscard

How is that simpler than

  when cond monadicComputationWhoseResultIWantToDiscard

which it would be with the suggested new type?

   Julian



More information about the Haskell mailing list