"do" notation and ">>"

Antony Courtney antony@apocalypse.org
Wed, 27 Mar 2002 22:31:00 -0500


James B. White III (Trey) wrote:
>>===== Original Message From Sigbjorn Finne <sof@galois.com> =====
>>Section 3.14 presents a bunch of identities that hold
>>for "do", but only suggests that these might be used by a Haskell system
>>when desugaring "do" expressions.
> 
> 
> The version of the report that I have states, "Do expressions satisfy these 
> identities..." I read this as a requirement, not a mere suggestion. It doesn't 
> read, "might satisfy," or, "can satisfy," but just, "satisfy". Is there a 
> newer 
> version of the report that weakens this?
> 
> This is not a mere academic curiosity to me. My application needs the 
> ability to redefine ">>" and have it work correctly using "do" notation. I 
> don't 
> yet understand why the inability of Hugs (and GHC, apparently) to support 
> this is anything other than nonconformance with Haskell 98.

Although not stated as an explicit requirement, I thought it was pretty 
clear that the default definition of (>>) in terms of (>>=), i.e.:
    m >> k  =  m >>= \_ -> k
was also a requirement that every "monad" must satisfy.

If your monad obeys this identity, then why would you care whether the 
syntactic sugar expands using (>>) or (>>=)?  And if your monad doesn't 
satisfy this identity, are you sure the type you are working with is 
really a monad?

	-antony

-- 
Antony Courtney
Grad. Student, Dept. of Computer Science, Yale University
antony@apocalypse.org          http://www.apocalypse.org/pub/u/antony