
I agree that this kind of backward-compatibility pattern synonym is good and shouldn't be prefixed with PS_. But do you have a concrete example of this leakage of an internal GHC type via TH? While I can imagine this happening, I don't know of any examples in practice. Note that even enumeration types (like Role) have separate TH counterparts. Richard
On Dec 29, 2021, at 6:12 PM, Viktor Dukhovni
wrote: Some "GHC-internal" types leak to users via TH, and their constructors occasionally pick up new fields, causing breakage downstream. The extra field often has a sensible default (Nothing, [], ...) and it should be best practice to rename the constructor when adding the new field, while replacing the original constructor with a pattern synonym with the "old" signature.
data Foo = ... | NewImprovedMkFoo X Y Z -- was MkFoo Y Z
pattern MkFoo :: Foo pattern MkFoo Y Z = NewImprovedMkFoo Nothing Y Z
When pattern synonyms are used to maintain a backwards-compatible API, there should of course be no special signalling to differentiate them from "real" constructors.
The boundary between "GHC-internal" and external may not always be obvious, some care is required to reduce leaking breakage via TH.
-- Viktor. _______________________________________________ ghc-devs mailing list ghc-devs@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs