@@ -5,8 +5,8 @@ module Data.FileEmbed
55 ) where
66
77import Language.Haskell.TH (runQ,
8− Exp(AppE, ListE, LitE, TupE),
9− Lit(IntegerL, StringL),
8+ Exp (AppE, ListE, LitE, TupE),
9+ Lit (StringL),
1010 Q,
1111 runIO)
1212import System.Directory (doesDirectoryExist, doesFileExist,
@@ -30,13 +30,13 @@ pairToExp (path, bs) = do
3030
3131bsToExp :: B.ByteString -> Q Exp
3232bsToExp bs = do
33− pack <- runQ [| B.pack |]
34− return $!
35− AppE pack .
36− ListE .
37− map (LitE . IntegerL . fromIntegral) .
38− B.unpack $
39− bs
33+ helper <- runQ [| stringToBs |]
34+ let octets = B.unpack bs
35+ let chars = map (toEnum . fromEnum) octets
36+ return $! AppE helper $! LitE $! StringL chars
37+
38+stringToBs :: String -> B.ByteString
39+stringToBs = B.pack . map (toEnum . fromEnum)
4040
4141notHidden :: FilePath -> Bool
4242notHidden ('.':_) = False