对我得到的结果有点困惑。使用以下内容:
GHCi, version 7.4.2: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude> :m + Language.Haskell.TH
我得到了这个成功的结果:
Prelude Language.Haskell.TH> runQ [d| data X = X |]
[DataD [] X_0 [] [NormalC X_1 []] []]
但我得到这个错误:
Prelude Language.Haskell.TH> runQ [d| data X = X deriving Show |]
<interactive>:4:30:
The exact Name `X' is not in scope
Probable cause: you used a unique name (NameU) in Template Haskell but did not bind it
In the Template Haskell quotation [d| data X = X deriving (Show) |]
In the first argument of `runQ', namely
`[d| data X = X deriving (Show) |]'
In the expression: runQ [d| data X = X deriving (Show) |]
使用 Template Haskell 时无法派生 Show?