Created
July 27, 2018 01:38
-
-
Save Saul-Mirone/a2ac7e3fa05b338152752d0e625c6f75 to your computer and use it in GitHub Desktop.
A mini file-embed using Template Haskell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE TemplateHaskell #-} | |
module TH | |
( embedFile ) | |
where | |
import Data.String (IsString (..)) | |
import Language.Haskell.TH | |
import Language.Haskell.TH.Syntax | |
embedFile :: FilePath -> Q Exp | |
embedFile path = do | |
str <- runIO (readFile path) | |
addDependentFile path | |
[| fromString str |] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment