[GHC] #12426: Allow smart constructors their own types

#12426: Allow smart constructors their own types -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: Type: feature | Status: new request | Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 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: -------------------------------------+------------------------------------- GHC currently offers one-way pattern synonyms allowing general deconstruction with nice syntax. And it offers bidirectional pattern synonyms, which toss in construction functions that start with capital letters. Unfortunately, it forces the construction and deconstruction sides to share a type. This is sometimes rather unfortunate. The documentation itself points out the limitation with regard to matching numeric literals (where deconstruction requires `Eq`). Another example is Edward Yang's `NF` type, whose smart constructor (but not deconstructor) requires `NFData`. I think the easiest fix is to allow a type signature in the `where` clause of a pattern synonym definition. {{{#!hs pattern X :: Eq a => a -> Foo pattern X q <- ... where X :: X a => a -> Foo X a = ... }}} Ideally, I'd like to offer the other one-way (constructor without pattern) as well, but I care less about that. }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12426 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12426: Allow smart constructors their own types -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: Type: feature request | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 Resolution: | Keywords: | PatternSynonyms Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #8581 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by mpickering): * keywords: => PatternSynonyms * related: => #8581 Comment: This is essentially #8581. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12426#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12426: Allow smart constructors their own types -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: Type: feature request | Status: closed Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 Resolution: duplicate | Keywords: | PatternSynonyms Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #8581 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: new => closed * resolution: => duplicate Comment: Let's mark it as a duplicate in that case. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12426#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC