|
[ ghc-Bugs-978068 ] arrow syntax example can't be parsed: msg#00037lang.haskell.glasgow.bugs
Bugs item #978068, was opened at 2004-06-23 11:08 Message generated for change (Tracker Item Submitted) made by Item Submitter 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 ---------------------------------------------------------------------- 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: | TH: calling fail in Q monad gives uninformative error message, and error causes panic, Duncan Coutts |
|---|---|
| Next by Date: | [ ghc-Bugs-978107 ] arrow notation example can't be parsed, SourceForge.net |
| Previous by Thread: | TH: calling fail in Q monad gives uninformative error message, and error causes panic, Duncan Coutts |
| Next by Thread: | [ ghc-Bugs-978068 ] arrow syntax example can't be parsed, SourceForge.net |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |