Adding an ignore function to Control.Monad

John Lato jwlato at gmail.com
Thu Jun 11 16:55:56 EDT 2009


> From: David Menendez <dave at zednenem.com>
> On Thu, Jun 11, 2009 at 1:53 PM, Sittampalam,
> Ganesh<ganesh.sittampalam at credit-suisse.com> wrote:
>> David Menendez wrote:
>>> On Thu, Jun 11, 2009 at 9:37 AM, Sittampalam,
>>> Ganesh<ganesh.sittampalam at credit-suisse.com> wrote:
>>
>>>> The main issue (IMO) is that do notation uses (>>) in the desugaring,
>>>> which in turn means that it supports statements that just throw away
>>>> not () results.
>>>
>>> How is that a problem? The whole *point* of (>>) is that it discards
>>> unneeded return values.
>>
>> I think we should avoid having syntax that implicitly does this. So
>>
>> do getLine
>>   return 3
>>
>> should be banned, and users should be forced to write something like
>>
>> do getLine >> ignore
>>   return 3
>>
>> or
>>
>> do _ <- getLine
>>   return 3
>>
>> Ganesh
>
> Again, why do you think that? I much prefer the current syntax.

IMO this is a tricky issue.  On the one hand, it's clear with
do-notation that the result of a line is being ignored because it
isn't explicitly handled.  On the other hand, this strikes me as
antithetical to the spirit of the language.  I somewhat grudgingly
agree with Henning and Ganesh that the syntax should prevent
accidentally ignoring values when possible.  I say grudgingly because
I also prefer the current syntax. although if it were going to change
my next favorite option is

do ignore getLine
     return 3

John


More information about the Libraries mailing list