[GHC] #13321: Importing a bundled pattern "infects" all other imports of that pattern

#13321: Importing a bundled pattern "infects" all other imports of that pattern -------------------------------------+------------------------------------- Reporter: ezyang | Owner: (none) Type: bug | Status: new Priority: low | Milestone: Component: Compiler | Version: 8.0.1 (Type checker) | 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: -------------------------------------+------------------------------------- Consider: {{{ {-# LANGUAGE PatternSynonyms #-} unit p where module A0 where data G = G Int module A1 where import A0 pattern X x = G x module A(G(X)) where import A0 import A1 module B(G) where import A module C(pattern X) where import A module D(N.G, pattern N.X) where import B import C import qualified A0 as N import qualified A1 as N }}} When we look at the interface for D, we see that N is bundled with D. This is a little surprising because I explicitly exported the G and X from A0 and A1, where no bundling took place. I suppose the current semantics might also be alright, but we should explicitly say so. The spec in the wiki is silent in this respect: https://ghc.haskell.org/trac/ghc/wiki/PatternSynonyms/AssociatingSynonyms -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13321 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13321: Importing a bundled pattern "infects" all other imports of that pattern -------------------------------------+------------------------------------- Reporter: ezyang | Owner: (none) Type: bug | Status: new Priority: low | Milestone: Component: Compiler (Type | Version: 8.0.1 checker) | 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 mpickering): I don't really understand this example sorry. What is a `unit`? How can `N` be bundled with anything (it isn't a pattern synonym)? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13321#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13321: Importing a bundled pattern "infects" all other imports of that pattern -------------------------------------+------------------------------------- Reporter: ezyang | Owner: (none) Type: bug | Status: new Priority: low | Milestone: Component: Compiler (Type | Version: 8.0.1 checker) | 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 rwbarton): Replying to [comment:1 mpickering]:
What is a `unit`?
A backpack thing. You can save this source as a single file `U.bkp` and build it with `ghc --backpack U.bkp`. In this case it's equivalent to just writing six `.hs` files. (I just learned about this from this ticket.)
How can `N` be bundled with anything (it isn't a pattern synonym)?
It should read "When we look at the interface for D, we see that X is bundled with G", I assume. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13321#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13321: Importing a bundled pattern "infects" all other imports of that pattern -------------------------------------+------------------------------------- Reporter: ezyang | Owner: (none) Type: bug | Status: new Priority: low | Milestone: Component: Compiler (Type | Version: 8.0.1 checker) | 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 ezyang): Yes, rwbarton is exactly right. Here's a self-contained example that doesn't involve looking at the interface file: {{{ {-# LANGUAGE PatternSynonyms #-} unit p where module A0 where data G = G Int module A1 where import A0 pattern X x = G x module A(G(X)) where import A0 import A1 module B(G) where import A module C(pattern X) where import A module D(N.G, pattern N.X) where import B import C import qualified A0 as N import qualified A1 as N module E where import D(G(..)) f (X x) = x -- X is in scope }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13321#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13321: Importing a bundled pattern "infects" all other imports of that pattern -------------------------------------+------------------------------------- Reporter: ezyang | Owner: (none) Type: bug | Status: new Priority: low | Milestone: Component: Compiler (Type | Version: 8.0.1 checker) | 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: | -------------------------------------+------------------------------------- Description changed by ezyang: Old description:
Consider:
{{{ {-# LANGUAGE PatternSynonyms #-} unit p where module A0 where data G = G Int module A1 where import A0 pattern X x = G x module A(G(X)) where import A0 import A1 module B(G) where import A module C(pattern X) where import A module D(N.G, pattern N.X) where import B import C import qualified A0 as N import qualified A1 as N }}}
When we look at the interface for D, we see that N is bundled with D. This is a little surprising because I explicitly exported the G and X from A0 and A1, where no bundling took place.
I suppose the current semantics might also be alright, but we should explicitly say so. The spec in the wiki is silent in this respect: https://ghc.haskell.org/trac/ghc/wiki/PatternSynonyms/AssociatingSynonyms
New description: Consider: {{{ {-# LANGUAGE PatternSynonyms #-} unit p where module A0 where data G = G Int module A1 where import A0 pattern X x = G x module A(G(X)) where import A0 import A1 module B(G) where import A module C(pattern X) where import A module D(N.G, pattern N.X) where import B import C import qualified A0 as N import qualified A1 as N }}} When we look at the interface for D, we see that X is bundled with G. This is a little surprising because I explicitly exported the G and X from A0 and A1, where no bundling took place. I suppose the current semantics might also be alright, but we should explicitly say so. The spec in the wiki is silent in this respect: https://ghc.haskell.org/trac/ghc/wiki/PatternSynonyms/AssociatingSynonyms -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13321#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC