Skip to content

TH cannot splice patterns in declaration quotes

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 |]
Trac metadata
Trac field Value
Version 7.2.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Template Haskell
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information