Cannot generate inline pragmas for pattern synonyms using TH
Summary
When generating pattern synonyms with TH it is currently not possible to also produce an inline pragma for that pattern with TH.
Steps to reproduce
module T1 where
import Language.Haskell.TH
genPat :: Q [Dec]
genPat = sequence [
patSynD name (prefixPatSyn []) unidir wildP
, pure $ PragmaD $ InlineP name Inline FunLike AllPhases
]
where name = mkName "A"
{-# LANGUAGE TemplateHaskell #-}
module T2 where
import T1
genPat
Fails with:
src/T2.hs:6:1: error: [GHC-55017]
Illegal variable name: ‘A’
When splicing a TH declaration: {-# INLINE A #-}
|
6 | genPat
Expected behavior
This code compiles just fine and I think so should the TH version that generates it.
{-# LANGUAGE PatternSynonyms #-}
module T2 where
pattern A <- _
{-# INLINE A #-}
Environment
- GHC version used: 9.4.4 and I also tested some recent form of the master branch (1-2 weeks old)