Bugs item #978068, was opened at 2004-06-23 02:08
Message generated for change (Comment added) made by nobody
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=108032&aid=978068&group_id=8032
Category: Documentation
Group: 6.2
Status: Open
Resolution: None
Priority: 5
Submitted By: John Hughes (rjmh)
Assigned to: Nobody/Anonymous (nobody)
Summary: arrow syntax example can't be parsed
Initial Comment:
This example from section 7.6 of the user guide can't be
parsed by the compiler:
expr' = proc x ->
returnA -< x
<+> do
symbol Plus -< ()
y <- term -< ()
expr' -< x + y
<+> do
symbol Minus -< ()
y <- term -< ()
expr' -< x - y
The reason is that the first <+> is wrongly parsed as
part of the previous expression (x <+> ...) rather than
as a command operator. The fix is either to enclose the
first command (returnA -< x) in parentheses, or precede
it with do so that the layout rule terminates the
command before the <+>. (The second use of <+> is OK
precisely because the layout rule terminates the
previous command before it).
Apart from fixing the example, I think it would be worth
commenting the problem -- this is a syntax "gotcha"
that is easy to stumble over. Maybe add this just after
the example above:
"Note that a command operator risks being interpreted
as a part of the expression at the end of the preceding
command. To prevent this, such a command should
either be enclosed in parentheses, or terminated by the
layout rule before the operator. The example above
would be parsed wrongly if the do before the returnA
were omitted."
This assumes it's fixed by inserting a do, of course!
John
----------------------------------------------------------------------
Comment By: Nobody/Anonymous (nobody)
Date: 2004-06-23 07:25
Message:
Logged In: NO
Indeed I thought I could simplify the example by removing
the "do". The error is obvious in retrospect, and the same
gotcha exists with ordinary expressions, but I'll add a warning.
Ross
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=108032&aid=978068&group_id=8032
_______________________________________________
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs