@@ -18,6 +18,10 @@ import WaiAppStatic.Types
18import WaiAppStatic.Storage.Filesystem (defaultWebAppSettings)
18import WaiAppStatic.Storage.Filesystem (defaultWebAppSettings)
19import qualified Data.ByteString as B
19import qualified Data.ByteString as B
20import qualified Data.ByteString.Lazy as BL
20import qualified Data.ByteString.Lazy as BL
21+#if !MIN_VERSION_template_haskell(2, 8, 0)
22+import qualified Data.ByteString.Char8 as B8
23+import qualified Data.ByteString.Lazy.Char8 as BL8
21import qualified Data.HashMap.Strict as M
25import qualified Data.HashMap.Strict as M
22import qualified Data.Text as T
26import qualified Data.Text as T
23import qualified Data.Text.Encoding as T
27import qualified Data.Text.Encoding as T
@@ -71,15 +75,30 @@ data ReloadEntry = ReloadEntry {
71-- the IORef will always be holding (NoFinalizers, []). Therefore
75-- the IORef will always be holding (NoFinalizers, []). Therefore
72-- unsafeDupablePerformIO is safe.
76-- unsafeDupablePerformIO is safe.
73bytestringE :: B.ByteString -> ExpQ
77bytestringE :: B.ByteString -> ExpQ
78+#if MIN_VERSION_template_haskell(2, 8, 0)
74bytestringE b = [| unsafeDupablePerformIO (unsafePackAddressLen (I# $lenE) $ctE) |]
79bytestringE b = [| unsafeDupablePerformIO (unsafePackAddressLen (I# $lenE) $ctE) |]
76 lenE = litE $ intPrimL $ toInteger $ B.length b
81 lenE = litE $ intPrimL $ toInteger $ B.length b
77 ctE = litE $ stringPrimL $ B.unpack b
82 ctE = litE $ stringPrimL $ B.unpack b
87+ s = litE $ stringL $ B8.unpack b
78bytestringLazyE :: BL.ByteString -> ExpQ
90bytestringLazyE :: BL.ByteString -> ExpQ
91+#if MIN_VERSION_template_haskell(2, 8, 0)
79bytestringLazyE b = [| unsafeDupablePerformIO (unsafePackAddressLen (I# $lenE) $ctE) |]
92bytestringLazyE b = [| unsafeDupablePerformIO (unsafePackAddressLen (I# $lenE) $ctE) |]
81 lenE = litE $ intPrimL $ toInteger $ BL.length b
94 lenE = litE $ intPrimL $ toInteger $ BL.length b
82 ctE = litE $ stringPrimL $ BL.unpack b
95 ctE = litE $ stringPrimL $ BL.unpack b
100+ s = litE $ stringL $ BL8.unpack b
84-- | A template haskell expression which creates either an EmbeddedEntry or ReloadEntry.
103-- | A template haskell expression which creates either an EmbeddedEntry or ReloadEntry.
85mkEntry :: EmbeddableEntry -> ExpQ
104mkEntry :: EmbeddableEntry -> ExpQ