[GHC] #13307: Record pattern synonym fields have to be manually exported
GHC
ghc-devs at haskell.org
Mon Feb 20 18:35:43 UTC 2017
#13307: Record pattern synonym fields have to be manually exported
-------------------------------------+-------------------------------------
Reporter: ocharles | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.0.2
Resolution: | Keywords:
| PatternSynonyms
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 rwbarton):
The real underlying goal here is to export `T`, `MkT2` and `x`, without
having to mention `x`, or export `MkT`.
mpickering and I discussed this over IRC and we converged (at least for
the moment) on this sketch of a design.
* Things can have associated things. Automatically associated to a type
are its constructors and record fields. Automatically associated to a
pattern synonym are its record fields. (And so on for classes, etc.)
* The effect of association is: `Foo(..)` in an export or import list
means "Foo and all the things associated to `Foo`".
* You can associate a pattern synonym to a type with the `T(P)` export
list form (this is the same as "bundling", and maybe I should just use the
word "bundled" everywhere). (And it might be useful for other things as
well; for example, if you change a class method to a top-level function,
by bundling the function with the class, you can preserve the meaning of
importing `C(..)`.)
* Things being associated is transitive, so then the fields of the pattern
synonym are associated with the type, too. This means that in particular
> `T( MkT, MkT2, .. )` means "`T` together with data
constructor/pattern synonyms `MkT` and `MkT2`, ''plus their field
names''".
However merely associating a field name `x` of `MkT` with the type `T`
''does not mean'' that exporting `( T( MkT ) )` causes `x` to be exported;
because there is no `..` in `T( MkT )`. So, I think that this design is
backwards compatible with the Haskell 2010 meaning of `..`.
Then, the other thing that is needed is the ability to write either
{{{
T( MkT2(..) )
}}}
or
{{{
T( MkT2 ), pattern MkT2(..)
}}}
in an export list (or import list) to export (or import) `MkT2` along with
all of its associated things. This is already the meaning of the
constructions `T(..)` and `C(..)` in Haskell 2010, so this seems like
mostly a parser change.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13307#comment:6>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list