{-# 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" FilePath -> Q () forall (m :: * -> *). Quasi m => FilePath -> m () qAddDependentFile FilePath fp FilePath d <- IO FilePath -> Q FilePath forall a. IO a -> Q a runIO (IO FilePath -> Q FilePath) -> IO FilePath -> Q FilePath 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 = Exp -> Q Exp forall (m :: * -> *) a. Monad m => a -> m a return (Exp -> Q Exp) -> Exp -> Q Exp forall a b. (a -> b) -> a -> b $ Name -> Exp VarE 'fromString Exp -> Exp -> Exp `AppE` Lit -> Exp LitE (FilePath -> Lit StringL FilePath s)