Do-notation
nilsson@cs.yale.edu
nilsson@cs.yale.edu
Thu, 28 Mar 2002 11:48:25 -0500
Olaf Chitil wrote:
> > I am certain that was not the intention of the authors. So one
> > possibility is to change the second line to read
> >
> > do {e;stmts} = e >>= (\ _ -> do {stmts})
> >
> > and that is what I *propose* to do.
> >
> > However, James implies that in his monad (>>) has a different meaning
> > than its usual one, and Haskell 98 allows that because (>>) is one of
> > the class operations (not a good design choice I think). I'm quite
> > reluctant to make the meaning of do-notation dependent on such
> > differences.
>
> I disagree. Hugs should be changed, not the report. In my opinion (>>)
> is a class operation, because there may be more efficient
> implementations of (>>) than the default one (\x y -> x >>= \_ -> y).
> The do notation should profit from a more efficient implementation.
I agree with Olaf (and James).
Incidentally, similar concerns occur in the context of the arrows framework.
Ross Paterson, in response to a request from us at Yale, recently changed
some derived arrow combinators into default methods of the arrow classes in
his implementation of the framework to allow more efficient, instance
specific, implementations of these combinators. Our request was prompted
by our work of (A)FRP, an embedded language.
/Henrik
--
Henrik Nilsson
Yale University
Department of Computer Science
nilsson@cs.yale.edu