{-# LANGUAGE TemplateHaskell #-} module Text.Pandoc.Filter.Plot.Scripting.Template (sourceTemplate_) where import Data.String (fromString) import Language.Haskell.TH.Syntax ( Exp (AppE, LitE, VarE), Lit (StringL), Q, Quasi (qAddDependentFile), runIO, ) import System.FilePath ((</>)) sourceTemplate_ :: Q Exp sourceTemplate_ :: Q Exp sourceTemplate_ = do let fp :: FilePath fp = FilePath "data" FilePath -> FilePath -> FilePath </> FilePath "srctemplate.html" forall (m :: * -> *). Quasi m => FilePath -> m () qAddDependentFile FilePath fp FilePath d <- forall a. IO a -> Q a runIO forall a b. (a -> b) -> a -> b $ FilePath -> IO FilePath readFile FilePath fp FilePath -> Q Exp strToExp FilePath d where strToExp :: String -> Q Exp strToExp :: FilePath -> Q Exp strToExp FilePath s = forall (m :: * -> *) a. Monad m => a -> m a return forall a b. (a -> b) -> a -> b $ Name -> Exp VarE 'fromString Exp -> Exp -> Exp `AppE` Lit -> Exp LitE (FilePath -> Lit StringL FilePath s)