diff options
author | Vladislav Zavialov <vlad.z.4096@gmail.com> | 2020-05-29 13:50:02 +0300 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-06-01 06:41:18 -0400 |
commit | 0fde53770cacb0d54f0583707ef7ceec78f92c41 (patch) | |
tree | 978537c734d65232080212b9580cf7fcb2daf077 /docs | |
parent | 730fcd54467e82083d56fa87e44bbe346458c531 (diff) | |
download | haskell-0fde53770cacb0d54f0583707ef7ceec78f92c41.tar.gz |
Improve parser error messages for TypeApplications
With this patch, we always parse f @t as a type application,
thereby producing better error messages.
This steals two syntactic forms:
* Prefix form of the @-operator in expressions. Since the @-operator is
a divergence from the Haskell Report anyway, this is not a major loss.
* Prefix form of @-patterns. Since we are stealing loose infix form
anyway, might as well sacrifice the prefix form for the sake of much
better error messages.
Diffstat (limited to 'docs')
-rw-r--r-- | docs/users_guide/bugs.rst | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/docs/users_guide/bugs.rst b/docs/users_guide/bugs.rst index 4dc49f0328..b5ac79d457 100644 --- a/docs/users_guide/bugs.rst +++ b/docs/users_guide/bugs.rst @@ -76,13 +76,20 @@ Lexical syntax See `GHC Proposal #229 <https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0229-whitespace-bang-patterns.rst>`__ for the precise rules. -- As-patterns must not be surrounded by whitespace:: +- As-patterns must not be surrounded by whitespace on either side:: f p@(x, y, z) = ... -- accepted by both GHC and the Haskell Report - f p @ (x, y, z) = ... -- accepted by the Haskell Report but not GHC - When surrounded by whitespace, ``(@)`` is treated by GHC as a regular infix - operator. + -- accepted by the Haskell Report but not GHC: + f p @ (x, y, z) = ... + f p @(x, y, z) = ... + f p@ (x, y, z) = ... + + When surrounded by whitespace on both sides, ``(@)`` is treated by GHC as a + regular infix operator. + + When preceded but not followed by whitespace, ``(@)`` is treated as a + visible type application. See `GHC Proposal #229 <https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0229-whitespace-bang-patterns.rst>`__ for the precise rules. |