Template Haskell: dataToExpQ and constructor mis-match
Conal Elliott
conal at conal.net
Tue Jan 24 18:55:35 CET 2012
I'm looking for a reliable way to turn values into Template Haskell
expressions. I thought dataToExpQ from Language.Haskell.TH.Quote was the
ticket, but it appears to produce constructors different from those
produced by [| ... |], including [], (:), (), and (,). Here's an example
run for (). I'm using template-haskell-2.5.0.0:
GHCi, version 7.0.4: http://www.haskell.org/ghc/ :? for help
Prelude> import Data.Data
Prelude Data.Data> import Language.Haskell.TH
Prelude Data.Data Language.Haskell.TH> :set -XTemplateHaskell
Prelude Data.Data Language.Haskell.TH> import Language.Haskell.TH.Quote
Prelude Data.Data Language.Haskell.TH Language.Haskell.TH.Quote> u1 <-
runQ (dataToExpQ (const Nothing) ())
Prelude Data.Data Language.Haskell.TH Language.Haskell.TH.Quote> u2 <-
runQ [| () |]
Prelude Data.Data Language.Haskell.TH Language.Haskell.TH.Quote> u1
ConE ()
Prelude Data.Data Language.Haskell.TH Language.Haskell.TH.Quote> u2
ConE GHC.Unit.()
Prelude Data.Data Language.Haskell.TH Language.Haskell.TH.Quote> u1 ==
u2
False
Any suggestions?
-- Conal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20120124/870f084a/attachment.htm>
More information about the Libraries
mailing list