"do" notation and ">>"

Sigbjorn Finne sof@galois.com
Wed, 27 Mar 2002 13:47:04 -0800


 "James B. White III (Trey)" <whitejbiii@ornl.gov> writes:
>
> Hugs appears to ignore definitions of ">>" when using "do" notation,
> perhaps relying on the default definition in terms of ">>=". Here is an
example.
>
> According to the Haskell 98 Tutorial, the following two statements
> should be equivalent, right?
>
> main = do put "hello"; put "world"
>
> main' = put "hello" >> put "world"
>

Hi,

well observed & reported. To be very precise about this issue, the
Haskell98 Report doesn't really fix the translation/desugaring rules for
the "do" notation -- 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.

Both GHC and Hugs desugars "do{ e ; stmts }" as
"e >>= \ _ -> do{stmts}", rather than "e >> do {stmts}", which explains
the discrepancy between expected and actual output.

Until the wording in the Report is either strengthened or GHC is also
changed
to use ">>" in the above, I'm reluctant to change Hugs right now.

Anyway, that's my thinking - others might feel differently; I'm in no way in
control of the Hugs sources.

--sigbjorn