Opened 6 years ago

Closed 6 years ago

Last modified 12 months ago

#5618 closed bug (invalid)

TH cannot splice patterns in declaration quotes

Reported by: Lennart Owned by:
Priority: normal Milestone:
Component: Template Haskell Version: 7.2.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


Try this:

{-# LANGUAGE TemplateHaskell #-}
module TH2 where
import Language.Haskell.TH

foo :: PatQ -> DecsQ
foo p = [d| $(p) = 1 |]

Or this

{-# LANGUAGE TemplateHaskell #-}
module TH3 where
import Language.Haskell.TH

foo :: PatQ -> DecsQ
foo p = [d| f $(p) = 1 |]

Change History (2)

comment:1 Changed 6 years ago by simonpj

Resolution: invalid
Status: newclosed

Well to be fair the manual says explicitly "Note that pattern splices are not supported. " (

But see my proposal for Template Haskell, which would support pattern splices. I totally lack cycles to act upon it.


comment:2 Changed 12 months ago by heisenbug

It seems to work in GHC v8.2.x:

Prelude Language.Haskell.TH> runQ ((\p -> [d| $(p) = 1 |] ) [p| hhh|]) >>= print
[ValD (VarP hhh_1) (NormalB (LitE (IntegerL 1))) []]
Note: See TracTickets for help on using tickets.