[GHC] #10653: PatternSynonyms should be imported/exported as part of the wildcard notation
GHC
ghc-devs at haskell.org
Sat Jul 18 20:14:52 UTC 2015
#10653: PatternSynonyms should be imported/exported as part of the wildcard
notation
-------------------------------------+-------------------------------------
Reporter: gridaphobe | Owner:
Type: feature request | Status: new
Priority: normal | Milestone: 7.12.1
Component: Compiler | Version: 7.11
Resolution: | Keywords: pattern
| synonyms
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Revisions:
-------------------------------------+-------------------------------------
Comment (by gridaphobe):
Replying to [comment:3 goldfire]:
> If `Q` belongs to pairs, then is it ever imported with `(..)` attached
to some type? I would guess "no".
Well I suppose it would be possible, since
{{{
import GHC.Tuple ((,)(..))
}}}
is a valid import declaration.
Here's how I imagine this working, if a module `M` exports a type `T` and
a pattern `P` whose result type is headed by `T`, e.g.
{{{
module M (T(..), pattern P) where
data T = T Int Int
pattern P x = T x 0
}}}
then a client module that uses a wildcard import, e.g.
{{{
module B where
import M ( T(..) )
}}}
should see `P` as well.
This rule would avoid any sort of spooky action at a distance, where `T`
and `P` are defined in separate modules, because the wildcard would only
depend on a single interface file.
That being said, I'm perfectly happy with goldfire's suggestion too :)
> What if there were a way to declare that a pattern is attached to a
type? For example:
>
> {{{
> module A ( A(.., pattern A1) ) where ...
> }}}
>
> By adding `A1` to the export list of the type `A`, then it is imported
with `A` as well. We would probably want a check that `A1`'s result type
is indeed headed by `A`. This seems to make sense in re-exports as well,
in case the pattern synonyms and original datatype are defined in
different modules.
One question though, if I have a client module
{{{
module B ( A(..) ) where
import A ( A(..) )
}}}
does `B` now export `A1` under your scheme, or does it need to explicitly
add `pattern A1` to the export declaration?
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10653#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list