I’m trying to export fields of 2 pattern synonyms in ghc 9.2.8 that have the same name but get an ambiguous name compiler error
module HaskellSandbox (A(A, x), B(B, x)) where
data A = MkA {x_ :: Int}
data B = MkB {x_ :: Int}
pattern A :: Int -> A
pattern A{x} <- MkA x
pattern B :: Int -> B
pattern B{x} <- MkB x
• Ambiguous occurrence ‘x’
It could refer to
either the field ‘x’,
defined at /home/jon/projects/haskell-sandbox/src/HaskellSandbox.hs:8:11
or the field ‘x’,
defined at /home/jon/projects/haskell-sandbox/src/HaskellSandbox.hs:11:11
• In the export: A(A, x)
My default extensions:
default-extensions:
GHC2021
DuplicateRecordFields
NoFieldSelectors
DerivingVia
GADTs
OverloadedStrings
PatternSynonyms
ViewPatterns
TemplateHaskell
TypeFamilies
DataKinds
LambdaCase
DefaultSignatures
RoleAnnotations
OverloadedLabels
DeriveAnyClass
If just exporting duplicate record field names I can do it
module HaskellSandbox (A(MkA, x), B(MkB, x)) where
data A = MkA {x :: Int}
data B = MkB {x :: Int}
Is there some syntax around this or am I really forced to define pattern synonyms with the same field names in different modules?