[GHC] #15457: (~) and (!) are parsed inconsistently in types (plus documentation warts)
#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
#15457: (~) and (!) are parsed inconsistently in types (plus documentation warts) -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: patch Priority: normal | Milestone: 8.8.1 Component: Compiler | Version: 8.4.3 (Parser) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5023 Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: new => patch * differential: => Phab:D5023 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15457#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#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) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: patch => new * differential: Phab:D5023 => Comment: The approach in Phab:D5023 isn't quite up to snuff, since it leaves some scenarios where `!` isn't parsed in a precedence-aware fashion (see https://phabricator.haskell.org/D5023#139341). To handle that situation correctly, we'd need to implement something skin to the plan laid out in https://phabricator.haskell.org/D5023#139245. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15457#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#15457: (~) and (!) are parsed inconsistently in types (plus documentation warts) -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: int-index Type: bug | Status: new Priority: normal | Milestone: 8.8.1 Component: Compiler | Version: 8.4.3 (Parser) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by int-index): * owner: (none) => int-index -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15457#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#15457: (~) and (!) are parsed inconsistently in types (plus documentation warts) -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: int-index Type: bug | Status: new Priority: normal | Milestone: 8.8.1 Component: Compiler | Version: 8.4.3 (Parser) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5180 Wiki Page: | -------------------------------------+------------------------------------- Changes (by int-index): * differential: => Phab:D5180 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15457#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#15457: (~) and (!) are parsed inconsistently in types (plus documentation warts) -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: int-index Type: bug | Status: new Priority: normal | Milestone: 8.8.1 Component: Compiler | Version: 8.4.3 (Parser) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5180 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Ryan Scott <ryan.gl.scott@…>): In [changeset:"bd7898537768f936d05c0c83eef1cd9b00933347/ghc" bd789853/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="bd7898537768f936d05c0c83eef1cd9b00933347" Parse the (!) type operator and allow type operators in existential context Summary: Improve the way `(!)`, `(~)`, and other type operators are handled in the parser, fixing two issues at once: 1. `(!)` can now be used as a type operator that respects fixity and precedence (#15457) 2. Existential context of a data constructor no longer needs parentheses (#15675) In addition to that, with this patch it is now trivial to adjust precedence of the `{-# UNPACK #-}` pragma, as suggested in https://ghc.haskell.org/trac/ghc/ticket/14761#comment:7 There was a small change to API Annotations. Before this patch, `(~)` was a strange special case that produced an annotation unlike any other type operator. After this patch, when `(~)` or `(!)` are used to specify strictness they produce AnnTilde and AnnBang annotations respectively, and when they are used as type operators, they produce no annotations. Test Plan: Validate Reviewers: simonpj, bgamari, alanz, RyanGlScott Reviewed By: RyanGlScott Subscribers: RyanGlScott, rwbarton, mpickering, carter GHC Trac Issues: #15457, #15675 Differential Revision: https://phabricator.haskell.org/D5180 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15457#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#15457: (~) and (!) are parsed inconsistently in types (plus documentation warts) -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: int-index Type: bug | Status: closed Priority: normal | Milestone: 8.8.1 Component: Compiler | Version: 8.4.3 (Parser) | Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | parser/should_compile/T15457 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5180 Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: new => closed * testcase: => parser/should_compile/T15457 * resolution: => fixed -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15457#comment:6> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC