Adding an ignore function to Control.Monad
john at repetae.net
Thu Jun 11 17:43:54 EDT 2009
On Thu, Jun 11, 2009 at 08:57:31PM +0200, Henning Thielemann wrote:
> On Thu, 11 Jun 2009, David Menendez wrote:
>> On Thu, Jun 11, 2009 at 1:53 PM, Sittampalam,
>> Ganesh<ganesh.sittampalam at credit-suisse.com> wrote:
>>> do _ <- getLine
>>> return 3
>> Again, why do you think that? I much prefer the current syntax.
And here I always get annoyed by types that specify '()' explicitly when
a universally quantified type will do. (`when` and `unless` are
particularly offensive in this regard). Forcing idioms to be more
verbose than necessary obscures intent.
Do we have any data that accidentally ignoring return values is a
problem in practice? I don't mean as it confused someone once and then
they learned their lesson. Because changing the type of (>>) would imply
extra effort always for everyone, whereas remembering that return values
might be important isn't exactly a recurring problem. It may save
someone a bug once when using System.system, but cause enough other code
to be obscured in meaning to hide a dozen other bugs. The fact you
currently don't assign a value to something means you probably would
have just mistakenly used 'ignore' in any case.
Also, treating '()' specially as 'don't care' as opposed to any other
unit type doesn't sit right with me either. Sure it is an obvious choice
for a don't care value, but the fact you can use others is nicely
consistent with the idea that other than having some syntatic sugar,
built in types are not special in haskell.
John Meacham - ⑆repetae.net⑆john⑈ - http://notanumber.net/
More information about the Libraries