[Haskell] Types of when and unless in Control.Monad
Christian Höner zu Siederdissen
choener at tbi.univie.ac.at
Sun Apr 22 13:39:18 CEST 2012
* Julian Gilbey <julian at d-and-j.net> [22.04.2012 09:22]:
> 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
Wouldn't "when_" and "unless_" or similar be better? I'd probably like
to have the compiler annoy me, since it is not clear that I want to
discard the result. If I really want to discard, I should have to make
it clear as there is probably a good reason for the inner function to
return a result in the first place?
Gruss,
Christian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/haskell/attachments/20120422/3f3a2281/attachment.pgp>
More information about the Haskell
mailing list