A little confused with the results I'm getting. Using the following:
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
I get this successful result:
Prelude Language.Haskell.TH> runQ [d| data X = X |]
[DataD [] X_0 [] [NormalC X_1 []] []]
But I get this error:
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) |]
I can't derive Show when using Template Haskell?
Looks like this was a bug in GHC that was fixed in version 7.6.1:
$ ~/bin/ghc-7.6.1/bin/ghci
GHCi, version 7.6.1: http://www.haskell.org/ghc/ :? for help
[...]
Prelude> :set -XTemplateHaskell
Prelude> import Language.Haskell.TH
Prelude Language.Haskell.TH> runQ [d| data X = X deriving (Show) |]
[...]
[DataD [] X_0 [] [NormalC X_1 []] [GHC.Show.Show]]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With