Original source code is here: https://github.com/hi-ogawa/haskell_playground/pull/14
As a starer, I experimented with I only did know
Is it possible to define in general way (not specific
Config record type)?
- Debug in ghci
> :set -XTemplateHaskell > :set -ddump-splices > :reload
> :set -ddump-deriv
typable, data class
From template-haskell-22.214.171.124, liftData is available.
liftData :: Data a => a -> Q Exp
If we use this, we don't have to define
instance Lift HExp by your own.
data HExp = HIntE Integer | HBinOpE HExp HBinOp HExp deriving (Show, Typeable, Data, Eq) data HBinOp = HAddO | HSubO | HMulO | HDivO deriving (Show, Typeable, Data, Eq) ... quoteHExp :: String -> TH.ExpQ quoteHExp s = do loc <- TH.location let (line, col) = TH.loc_start loc file = TH.loc_filename loc THS.liftData =<< doParse (file, line, col) s