Skip to content

Commit 5de3b6a

Browse files
committed
Switch from template-haskell to template-haskell-lift
1 parent 0178d46 commit 5de3b6a

File tree

4 files changed

+11
-23
lines changed

4 files changed

+11
-23
lines changed

Data/ByteString/Internal/Type.hs

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,7 @@ import GHC.Int (Int (..))
195195
import GHC.ForeignPtr (unsafeWithForeignPtr)
196196
#endif
197197

198-
import qualified Language.Haskell.TH.Lib as TH
199-
import qualified Language.Haskell.TH.Syntax as TH
198+
import qualified TemplateHaskell.Lift as TH
200199

201200
#if !HS_unsafeWithForeignPtr_AVAILABLE
202201
unsafeWithForeignPtr :: ForeignPtr a -> (Ptr a -> IO b) -> IO b
@@ -360,24 +359,13 @@ byteStringDataType = mkDataType "Data.ByteString.ByteString" [packConstr]
360359

361360
-- | @since 0.11.2.0
362361
instance TH.Lift ByteString where
363-
#if MIN_VERSION_template_haskell(2,16,0)
364-
-- template-haskell-2.16 first ships with ghc-8.10
365-
lift (BS ptr len) = [| unsafePackLenLiteral |]
366-
`TH.appE` TH.litE (TH.integerL (fromIntegral len))
367-
`TH.appE` TH.litE (TH.BytesPrimL $ TH.Bytes ptr 0 (fromIntegral len))
368-
#else
369-
lift bs@(BS _ len) = [| unsafePackLenLiteral |]
370-
`TH.appE` TH.litE (TH.integerL (fromIntegral len))
371-
`TH.appE` TH.litE (TH.StringPrimL $ unpackBytes bs)
372-
#endif
362+
lift (BS ptr len) =
363+
[| unsafePackLenLiteral
364+
$(TH.lift len)
365+
$(TH.liftAddrCompat ptr 0 (fromIntegral len))
366+
|]
373367

374-
#if MIN_VERSION_template_haskell(2,17,0)
375-
-- template-haskell-2.17 first ships with ghc-9.0
376-
liftTyped = TH.unsafeCodeCoerce . TH.lift
377-
#elif MIN_VERSION_template_haskell(2,16,0)
378-
-- template-haskell-2.16 first ships with ghc-8.10
379-
liftTyped = TH.unsafeTExpCoerce . TH.lift
380-
#endif
368+
liftTyped = TH.defaultLiftTyped
381369

382370
------------------------------------------------------------------------
383371
-- Internal indexing

Data/ByteString/Lazy/Internal.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ import Data.Data (Data(..), mkConstr ,mkDataType, Constr, DataTyp
6363

6464
import GHC.Exts (IsList(..))
6565

66-
import qualified Language.Haskell.TH.Syntax as TH
66+
import qualified Language.Haskell.TH.Lift as TH
6767

6868
#ifdef HS_BYTESTRING_ASSERTIONS
6969
import Control.Exception (assert)

Data/ByteString/Short/Internal.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ import qualified Data.ByteString.Lazy.Internal as LBS
248248

249249
import qualified Data.List as List
250250
import qualified GHC.Exts
251-
import qualified Language.Haskell.TH.Syntax as TH
251+
import qualified Language.Haskell.TH.Lift as TH
252252

253253
-- | A compact representation of a 'Word8' vector.
254254
--

bytestring.cabal

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ common language
109109

110110
library
111111
import: language
112-
build-depends: base >= 4.12 && < 5, ghc-prim, deepseq, template-haskell
112+
build-depends: base >= 4.12 && < 5, ghc-prim, deepseq, template-haskell-lift >= 0.1 && <0.2
113113

114114
if impl(ghc < 9.4)
115115
build-depends: data-array-byte >= 0.1 && < 0.2
@@ -222,7 +222,7 @@ test-suite bytestring-tests
222222
QuickCheck,
223223
tasty,
224224
tasty-quickcheck >= 0.8.1,
225-
template-haskell,
225+
template-haskell-lift,
226226
transformers >= 0.3,
227227
syb
228228

0 commit comments

Comments
 (0)