@@ -46,11 +46,7 @@ module Data.FileEmbed
4646
4747import Language.Haskell.TH.Syntax
4848 ( Exp (AppE, ListE, LitE, TupE, SigE, VarE)
49−#if MIN_VERSION_template_haskell(2,5,0)
50− , Lit (StringL, StringPrimL, IntegerL)
51−#else
52− , Lit (StringL, IntegerL)
53−#endif
49+ , Lit (..)
5450 , Q
5551 , runIO
5652 , qLocation, loc_filename
@@ -58,6 +54,10 @@ import Language.Haskell.TH.Syntax
5854 , Quasi(qAddDependentFile)
5955#endif
6056 )
57+#if MIN_VERSION_template_haskell(2,16,0)
58+import Language.Haskell.TH ( mkBytes, bytesPrimL )
59+import qualified Data.ByteString.Internal as B
60+#endif
6161import System.Directory (doesDirectoryExist, doesFileExist,
6262 getDirectoryContents, canonicalizePath)
6363import Control.Exception (throw, ErrorCall(..))
@@ -155,7 +155,11 @@ bsToExp bs =
155155 return $ VarE 'unsafePerformIO
156156 `AppE` (VarE 'unsafePackAddressLen
157157 `AppE` LitE (IntegerL $ fromIntegral $ B8.length bs)
158−#if MIN_VERSION_template_haskell(2, 8, 0)
158+#if MIN_VERSION_template_haskell(2, 16, 0)
159+ `AppE` LitE (bytesPrimL (
160+ let B.PS ptr off sz = bs
161+ in mkBytes ptr (fromIntegral off) (fromIntegral sz))))
162+#elif MIN_VERSION_template_haskell(2, 8, 0)
159163 `AppE` LitE (StringPrimL $ B.unpack bs))
160164#else
161165 `AppE` LitE (StringPrimL $ B8.unpack bs))