[GHC] #8961: Require PatternSynonyms language extension to *use* pattern synonyms

#8961: Require PatternSynonyms language extension to *use* pattern synonyms -------------------------------------------+------------------------------- Reporter: cactus | Owner: cactus Type: bug | Status: new Priority: normal | Milestone: 7.8.1 Component: Compiler (Type checker) | Version: 7.8.1-rc2 Keywords: | Operating System: Architecture: Unknown/Multiple | Unknown/Multiple Difficulty: Easy (less than 1 hour) | Type of failure: Blocked By: | None/Unknown Related Tickets: | Test Case: | Blocking: -------------------------------------------+------------------------------- To keep in the spirit of #2905, especially in light of the immaturity of the pattern synonyms extensions, GHC should require the `PatternSynonyms` language extension to be turned on when encountering a pattern synonym occurance. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8961 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8961: Require PatternSynonyms language extension to *use* pattern synonyms -------------------------------------+------------------------------------- Reporter: cactus | Owner: cactus Type: bug | Status: merge Priority: normal | Milestone: 7.8.1 Component: Compiler (Type | Version: 7.8.1-rc2 checker) | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: Unknown/Multiple | Difficulty: Easy (less than 1 Type of failure: None/Unknown | hour) Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------- Changes (by hvr): * status: new => merge Comment: Fixed via 60ec752c7e5378c8eeb556391ae34ab8c37426c4 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8961#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8961: Require PatternSynonyms language extension to *use* pattern synonyms -------------------------------------+------------------------------------- Reporter: cactus | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.8.1 Component: Compiler (Type | Version: 7.8.1-rc2 checker) | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: Unknown/Multiple | Difficulty: Easy (less than 1 Type of failure: None/Unknown | hour) Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------- Changes (by hvr): * owner: cactus => * status: merge => new Comment: nevermind, reverting status to new since this isn't yet in master -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8961#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8961: Require PatternSynonyms language extension to *use* pattern synonyms
-------------------------------------+-------------------------------------
Reporter: cactus | Owner:
Type: bug | Status: new
Priority: normal | Milestone: 7.8.1
Component: Compiler (Type | Version: 7.8.1-rc2
checker) | Keywords:
Resolution: | Architecture: Unknown/Multiple
Operating System: Unknown/Multiple | Difficulty: Easy (less than 1
Type of failure: None/Unknown | hour)
Test Case: | Blocked By:
Blocking: | Related Tickets:
-------------------------------------+-------------------------------------
Comment (by Dr. ERDI Gergo

#8961: Require PatternSynonyms language extension to *use* pattern synonyms -------------------------------------+------------------------------------- Reporter: cactus | Owner: Type: bug | Status: closed Priority: normal | Milestone: 7.8.1 Component: Compiler (Type | Version: 7.8.1-rc2 checker) | Keywords: Resolution: fixed | Architecture: Unknown/Multiple Operating System: Unknown/Multiple | Difficulty: Easy (less than 1 Type of failure: None/Unknown | hour) Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------- Changes (by thoughtpolice): * status: new => closed * resolution: => fixed Comment: Merged, thanks! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8961#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8961: Require PatternSynonyms language extension to *use* pattern synonyms -------------------------------------+------------------------------------- Reporter: cactus | Owner: Type: bug | Status: closed Priority: normal | Milestone: 7.8.1 Component: Compiler (Type | Version: 7.8.1-rc2 checker) | Keywords: Resolution: fixed | Architecture: Unknown/Multiple Operating System: Unknown/Multiple | Difficulty: Easy (less than 1 Type of failure: None/Unknown | hour) Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------- Comment (by simonpj): Is this documented in the user manual? If not, could it be, please? Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8961#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8961: Require PatternSynonyms language extension to *use* pattern synonyms -------------------------------------+------------------------------------- Reporter: cactus | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.8.1 Component: Compiler (Type | Version: 7.8.1-rc2 checker) | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: Unknown/Multiple | Difficulty: Easy (less than 1 Type of failure: None/Unknown | hour) Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------- Changes (by simonpj): * status: closed => new * resolution: fixed => -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8961#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8961: Require PatternSynonyms language extension to *use* pattern synonyms -------------------------------------+------------------------------------- Reporter: cactus | Owner: cactus Type: bug | Status: new Priority: normal | Milestone: 7.8.1 Component: Compiler (Type | Version: 7.8.1-rc2 checker) | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: Unknown/Multiple | Difficulty: Easy (less than 1 Type of failure: None/Unknown | hour) Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------- Changes (by simonpj): * owner: => cactus -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8961#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8961: Require PatternSynonyms language extension to *use* pattern synonyms -------------------------------------+------------------------------------- Reporter: cactus | Owner: cactus Type: bug | Status: closed Priority: normal | Milestone: 7.8.1 Component: Compiler (Type | Version: 7.8.1-rc2 checker) | Keywords: Resolution: fixed | Architecture: Unknown/Multiple Operating System: Unknown/Multiple | Difficulty: Easy (less than 1 Type of failure: None/Unknown | hour) Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------- Changes (by thoughtpolice): * status: new => closed * resolution: => fixed Comment: I went ahead and added this to the manual and cherry-picked it into 7.8, thanks for the note Simon. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8961#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8961: Require PatternSynonyms language extension to *use* pattern synonyms -------------------------------------+------------------------------------- Reporter: cactus | Owner: cactus Type: bug | Status: closed Priority: normal | Milestone: 7.8.1 Component: Compiler (Type | Version: 7.8.1-rc2 checker) | Keywords: Resolution: fixed | Architecture: Unknown/Multiple Operating System: Unknown/Multiple | Difficulty: Easy (less than 1 Type of failure: None/Unknown | hour) Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------- Comment (by isaacdupree): I'm sceptical of this change. It means a library module can't transparently replace a data type with a pattern synonym in a new version. Modules that depend on the library would break unless they add a flag. Unlike with GADTs, this ability is one of the reasons for pattern synonyms existing. (The consistency and immaturity arguments are tempting, though.) Is there a technical reason along the lines of #2905's `RelaxedPolyRec` that makes pattern-matching pattern synonyms work poorly without a language extension? -Isaac -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8961#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8961: Require PatternSynonyms language extension to *use* pattern synonyms -------------------------------------+------------------------------------- Reporter: cactus | Owner: cactus Type: bug | Status: closed Priority: normal | Milestone: 7.8.1 Component: Compiler (Type | Version: 7.8.1-rc2 checker) | Keywords: Resolution: fixed | Architecture: Unknown/Multiple Operating System: Unknown/Multiple | Difficulty: Easy (less than 1 Type of failure: None/Unknown | hour) Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------- Comment (by tibbe): I think it's very attractive to allow the change to be transparent to the user, as Isaac said. Imagine we want to change `String` to be an opaque type with a different representation. We could use a pattern synonym (and expression synonym?) to allow users who use `(:)` to be none the wiser. I admit that I haven't thought about all the implications though. Would it really be transparent to the user if a real constructor or a synonym is used? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8961#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8961: Require PatternSynonyms language extension to *use* pattern synonyms -------------------------------------+------------------------------------- Reporter: cactus | Owner: cactus Type: bug | Status: closed Priority: normal | Milestone: 7.8.1 Component: Compiler (Type | Version: 7.8.1-rc2 checker) | Keywords: Resolution: fixed | Architecture: Unknown/Multiple Operating System: Unknown/Multiple | Difficulty: Easy (less than 1 Type of failure: None/Unknown | hour) Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------- Comment (by simonpj): I was sceptical too. GHC's general convention is to require an extension at the ''definition'' site of something, but not its ''use'' site. For example, you can use a kind-polymorphic type constructor without `PolyKinds`; and you can use overlapping instances without `OverlappingInstances`. Really the only justification for not following this convention is if it's going to be hard for the user to understand what's going on. For example, a uni-directional pattern synonym can be used in a pattern but not an expression, and that would be puzzling if you had no idea that `K` is a pattern synonym. Also pattern matching on a pattern synonym might be much more expensive than pattern matching on a data constructor. And that kind of thing was the justification for #2905. FWIW, my own instinct is ''not'' to require `PatternSynonyms` at the use site; but I didn't feel strongly about it to reverse the choice. And it's easier to lift the restriction later than to add it. Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8961#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8961: Require PatternSynonyms language extension to *use* pattern synonyms -------------------------------------+------------------------------------- Reporter: cactus | Owner: cactus Type: bug | Status: closed Priority: normal | Milestone: 7.8.1 Component: Compiler (Type | Version: 7.8.1-rc2 checker) | Keywords: Resolution: fixed | Architecture: Unknown/Multiple Operating System: Unknown/Multiple | Difficulty: Easy (less than 1 Type of failure: None/Unknown | hour) Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------- Comment (by cactus): I did this because I thought requiring the language pragma at use sites is the more conservative choice, given that `PatternSynonyms` is more of a tech preview than a full feature yet (see #8581, #8582, #8583, #8779 for some of the missing features from the original proposal; #8584 and #8761 for more pressing issues, #8968 for a potentially deeper rabbit hole). If that is the consensus, I have no problems with reverting this, but I think for 7.8.1 we should leave this in so that it requires effort (and thus it cannot go unnoticed) if you use this feature. A future release with the above-mentioned problems addressed could then remove this hoop to jump through. So my vote is on keeping this. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8961#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC