[GHC] #12428: Allow pattern synonyms to optionally carry coerceability
GHC
ghc-devs at haskell.org
Thu Aug 11 14:47:53 UTC 2016
#12428: Allow pattern synonyms to optionally carry coerceability
-------------------------------------+-------------------------------------
Reporter: dfeuer | Owner:
Type: feature request | Status: new
Priority: normal | Milestone: 8.2.1
Component: Compiler | Version: 8.0.1
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: |
-------------------------------------+-------------------------------------
Comment (by dfeuer):
Replying to [comment:3 simonpj]:
> Could you give a specific, concrete example?
Suppose I have a module that defines a newtype
{{{#!hs
newtype Foo a = Foo a
}}}
Suppose this module has a zillion users, and at some point its maintainer
decides, for internal reasons, to change the definition of `Foo` to
{{{#!hs
newtype Foo a = Foo (Bar a)
}}}
where `Bar` is another newtype. She can expose a ''similar'' interface by
hiding the `Foo` constructor and instead exporting a pattern synonym
{{{#!hs
pattern Foo a = Foo (Bar a)
}}}
But the interface is not quite the same! If someone has a module that
imports hers and then uses the `Coercible a (Foo a)` instance, it will
simply stop working now that the actual `Foo` constructor is no longer
exported.
What I'm proposing is that pattern synonym writers who can see the actual
constructor should be able to "bless" their pattern synonyms with its
magical import/export power, and that this should be available
transitively. I ''don't'' want it to be automatic, because sometimes I
explicitly want to use a pattern synonym to block coercions.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12428#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list