Record pattern synonym fields have to be manually exported
The following currently fails to compile:
{-# LANGUAGE PatternSynonyms #-}
module A( T( MkT2 ) ) where
data Impl = Impl Int
newtype T = MkT Impl
pattern MkT2 {x} = MkT (Impl x)
{-# LANGUAGE RecordWildCards #-}
module B where
import A
foo :: T -> Int
foo MkT2{x} = x
As far as GHC can see, in module B, MkT2 does not have a field x. The fix is to manually export x from A:
module A (T(MkT2, x)) where
But this is tedious for records with a large amount of fields
Edited by Simon Peyton Jones