Adding an ignore function to Control.Monad

John Lato jwlato at gmail.com
Thu Jun 11 09:28:04 EDT 2009


> From: Henning Thielemann <lemming at henning-thielemann.de>
>
> Isaac Dupree schrieb:
>> On the other hand, maybe it's also an argument to change all the
>> functions like forkIO from
>> :: IO () -> IO ThreadID
>> to
>> :: IO a -> IO ThreadID
>>
>> I mean, surely they don't rely on the value of a () return-type, other
>> than to pass on to other places that artificially require the ()-type?
>
> 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!

John


More information about the Libraries mailing list