Olaf Chitil
Thu, 28 Mar 2002 19:10:54 +0000

Ross Paterson wrote:
> Yes, but in that case the specific implementations are required to be
> denotationally equal to the default versions.  And surely that was
> the original intention here.  Section 6.3.6 of the Report needs an
> additional equation:
>         m >> k  =  m >>= \_ -> k
> Then Hugs and GHC would be correct but suboptimal.

I agree that this equation should be in the report, but note that there
is no *requirement* that the monad laws hold for user defined instances.
The report merely states that they *should* hold. Maybe we should be
more clear what this word *should* means. I understand it as meaning
that the term "monad" suggests that these laws hold, that a programmer
should have very good reasons for breaking any of them and if a law is
broken a big warning should be attached to the code, because any user of
a monad expects it to fulfill the laws. However, because the laws cannot
be checked by an implementation, no implementation is allowed to make
use of them. In particular, the laws may accidentally have been broken
and if an implementation makes use of the laws, then the behaviour of
the resulting computation may be completely incomprehensible. (Just to
make clear that I don't advocate breaking these laws; but then I'm not a
fan of monads anyway...)


 Dept. of Computer Science, The University of York, York YO10 5DD, UK. 
 Tel: +44 1904 434756; Fax: +44 1904 432767