Skip to content

Importing a bundled pattern "infects" all other imports of that pattern

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

Edited by Edward Z. Yang
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information