Allow pragmas on field selectors.
Motivation
If we want to allow rules to match on field selectors, we would like to delay them being translated into pattern matches until the rules had a chance to fire.
Consider this snippet:
data T = MkT { foo :: Int }
{-# INLINE[1] foo #-}
currently ghc doesn't allow us to specify pragmas for the field selector.
A.hs:15:15: error:
The INLINE pragma for `foo' lacks an accompanying binding
(The INLINE pragma must be given where `foo' is declared)
|
15 | {-# INLINE[1] foo #-}
Proposal
In core we treat field selectors just like regular bindings. They generate code, are inlined, get unfoldings and so on.
So we should also allow users to reference them in pragmas just like regular bindings.
The frontend is not something I'm very familiar with so this might be tricky in practice depending on when we actually generate the selector bindings. But it seems like a reasonable request.