我正在尝试使用expression quotation撰写声明, 无论我尝试什么,编译器都会在模式上失败,并显示如下消息:
Parse error in pattern: $pattern
以下是一个例子:
{-# LANGUAGE TemplateHaskell, QuasiQuotes #-}
import Language.Haskell.TH
data A = A Int Int
decl :: DecsQ
decl = [d|
instance Show A where
show $pattern = undefined
|]
where
pattern = conP (mkName "A") $ map varP $ map mkName $ ["a", "b"]