Adding an ignore function to Control.Monad

Henning Thielemann lemming at henning-thielemann.de
Thu Jun 11 09:44:29 EDT 2009


Sittampalam, Ganesh schrieb:
> John Lato wrote:
>>> From: Henning Thielemann <lemming at henning-thielemann.de>
>>>
> 
>>> No, I think it is already bad enough, that (>>) has type (m a -> m b
>>> -> m b) instead of (m () -> m b -> m b). It is like automatically
>>> ignoring return values in C. It is too easy to ignore a result that
>>> is important. 
>> I agree with Henning on forkIO and the like, but I think the current
>> type of (>>) is right.  The name of the function is "anonymous bind"
>> (at least that's what I learned), and its whole purpose of existence
>> is to ignore the value of the first computation while maintaining the
>> context.   
>>
>> It would be nice if there were greater differentiation between (>>)
>> and (>>=), though.  Ideally, (>>) would be changed to something
>> longer than (>>=) to prevent accidental mis-typing (i.e. on the
>> keyboard). Not that I expect much support for this proposal!  
> 
> 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.

Yes that's my concern. Otherwise, when using (>>) explicitly I agree
with John.


More information about the Libraries mailing list