[GHC] #12426: Allow smart constructors their own types
GHC
ghc-devs at haskell.org
Sat Jul 23 02:34:51 UTC 2016
#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
More information about the ghc-tickets
mailing list