[GHC] #15457: (~) and (!) are parsed inconsistently in types (plus documentation warts)
GHC
ghc-devs at haskell.org
Mon Jul 30 14:46:15 UTC 2018
#15457: (~) and (!) are parsed inconsistently in types (plus documentation warts)
-------------------------------------+-------------------------------------
Reporter: RyanGlScott | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone: 8.8.1
Component: Compiler | Version: 8.4.3
(Parser) |
Keywords: | Operating System: Unknown/Multiple
Architecture: | Type of failure: None/Unknown
Unknown/Multiple |
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Rev(s): | Wiki Page:
-------------------------------------+-------------------------------------
(Spawned from
https://ghc.haskell.org/trac/ghc/ticket/10056?replyto=41#comment:41)
`~` and `!` are slightly special in the parser to allow strict annotations
and lazy annotations (with `-XStrict`) in data types. As a result, we
initially parse all uses of `~`/`!` as bangs, and we use a post-parsing
pass (`mergeOps`/`splitTilde`) to figure out which uses of `~` are
actually meant to refer to the equality type constructor.
There's a couple of unsatisfying things here:
1. `splitTilde` handles `~`, but not `!`. This means that any use of `!`
as a type operator will not work, as evidenced by this GHCi session:
{{{
λ> type a ! b = Either a b
<interactive>:1:6: error:
Malformed head of type or class declaration: a !b
}}}
We should update `splitTilde` to handle `!` as well. (And perhaps give
that function a new name to reflect its more ambitious goals.)
2. `Note [Parsing ~]` is supposed to explain all of this hullabaloo, but
it does a rather poor job of it. Let's add some more prose to it.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15457>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list