|
[ ghc-Bugs-978068 ] arrow syntax example can't be parsed: msg#00040lang.haskell.glasgow.bugs
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
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | [ ghc-Bugs-978107 ] arrow notation example can't be parsed, SourceForge.net |
|---|---|
| Next by Date: | [ ghc-Bugs-978543 ] "-M" option broken with "-hisuf prof.hi", SourceForge.net |
| Previous by Thread: | [ ghc-Bugs-978068 ] arrow syntax example can't be parsed, SourceForge.net |
| Next by Thread: | [ ghc-Bugs-978068 ] arrow syntax example can't be parsed, SourceForge.net |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |