Skip to content

Instantly share code, notes, and snippets.

@markhibberd
Created May 30, 2016 12:34
Show Gist options
  • Save markhibberd/669018f67777b96624648c799400abe2 to your computer and use it in GitHub Desktop.
Save markhibberd/669018f67777b96624648c799400abe2 to your computer and use it in GitHub Desktop.
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE QuasiQuotes #-}
module Boris.Http.TH (
embed
) where
import qualified Data.Text as T
import qualified Data.Text.IO as T
import Language.Haskell.TH
import Language.Haskell.TH.Syntax (qAddDependentFile)
import P
import System.IO (FilePath)
embed :: FilePath -> Q Exp
embed f = do
qAddDependentFile f
t <- runIO (T.readFile f)
appE (varE 'T.pack) . litE . StringL . T.unpack $ t
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment