on master help sign in
Support for template-haskell 2.7
commitbdc974a7c0e5b4a4f2c48cd24c3db4d66869fb1d authorMichael Snoyman <michael@snoyman.com> dateThu 12 Sep 2013, 10:07 (13 years ago) parent9222d4d
2 files changed+20−1
wai-app-static/WaiAppStatic/Storage/Embedded/TH.hs+19 wai-app-static/wai-app-static.cabal+1−1
wai-app-static/WaiAppStatic/Storage/Embedded/TH.hs+19
@@ -18,6 +18,10 @@ import WaiAppStatic.Types
1818import WaiAppStatic.Storage.Filesystem (defaultWebAppSettings)
1919import qualified Data.ByteString as B
2020import 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
24+#endif
2125import qualified Data.HashMap.Strict as M
2226import qualified Data.Text as T
2327import qualified Data.Text.Encoding as T
@@ -71,15 +75,30 @@ data ReloadEntry = ReloadEntry {
7175-- the IORef will always be holding (NoFinalizers, []). Therefore
7276-- unsafeDupablePerformIO is safe.
7377bytestringE :: B.ByteString -> ExpQ
78+#if MIN_VERSION_template_haskell(2, 8, 0)
7479bytestringE b = [| unsafeDupablePerformIO (unsafePackAddressLen (I# $lenE) $ctE) |]
7580 where
7681 lenE = litE $ intPrimL $ toInteger $ B.length b
7782 ctE = litE $ stringPrimL $ B.unpack b
83+#else
84+bytestringE b =
85+ [| B8.pack $s |]
86+ where
87+ s = litE $ stringL $ B8.unpack b
88+#endif
89+
7890bytestringLazyE :: BL.ByteString -> ExpQ
91+#if MIN_VERSION_template_haskell(2, 8, 0)
7992bytestringLazyE b = [| unsafeDupablePerformIO (unsafePackAddressLen (I# $lenE) $ctE) |]
8093 where
8194 lenE = litE $ intPrimL $ toInteger $ BL.length b
8295 ctE = litE $ stringPrimL $ BL.unpack b
96+#else
97+bytestringLazyE b =
98+ [| B8.pack $s |]
99+ where
100+ s = litE $ stringL $ BL8.unpack b
101+#endif
83102
84103-- | A template haskell expression which creates either an EmbeddedEntry or ReloadEntry.
85104mkEntry :: EmbeddableEntry -> ExpQ
wai-app-static/wai-app-static.cabal+1−1
@@ -48,7 +48,7 @@ library
4848 , cereal >= 0.3.5
4949 , mime-types >= 0.1 && < 0.2
5050 , unordered-containers >= 0.2
51− , template-haskell >= 2.8
51+ , template-haskell >= 2.7
5252 , zlib >= 0.5
5353
5454 exposed-modules: Network.Wai.Application.Static