[Haskell-cafe] Compile-time evaluation

Alfonso Acosta alfonso.acosta at gmail.com
Sat Nov 3 11:26:35 EDT 2007


Hi Nicholas,

> compileTimeEval :: Data a => a -> ExpQ
> compileTimeEval = return . toExp


> You're telling me all that horrendous pain in implementing toExp and
it already exists?!?

Yes unfortunately, compileTimeEval already exists in TH, it's called lift

compileTimeEval :: Lift a => a -> ExpQ
compileTimeEval = lift

But don't be so hard on yourself. Your approach has one advantage.
GHC supports automatic derivation of Data whereas Lift instances have
to be created manually.

Note, however, that Lift instances can also be generated using Igloo's
th-lift package[1].

Cheers,

Fons

[1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/th-lift-0.2


More information about the Haskell-Cafe mailing list