{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} module Interpolate (plugin) where import GhcPlugins import HsSyn import qualified Data.Generics as SYB plugin :: Plugin plugin = defaultPlugin { parsedResultAction = parsedPlugin } parsedPlugin :: [CommandLineOption] -> ModSummary -> HsParsedModule -> Hsc HsParsedModule parsedPlugin _ _ HsParsedModule{..} = do let hpm_module' = SYB.mkT transform `SYB.everywhere` hpm_module return $ HsParsedModule{ hpm_module = hpm_module', .. } transform :: HsExpr GhcPs -> HsExpr GhcPs transform (HsLit _ (HsString _ fs)) = HsSpliceE NoExt $ mkHsQuasiQuote (mkVarUnqual "i") noSrcSpan fs transform expr = expr