我正在尝试使用表达式 quote编写声明,并且无论我尝试什么,编译器都会在模式上失败,并显示如下消息:
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"]