@@ -195,8 +195,7 @@ import GHC.Int (Int (..))
195195import 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 Language.Haskell.TH.Lift as TH
200199
201200#if !HS_unsafeWithForeignPtr_AVAILABLE
202201unsafeWithForeignPtr :: 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
362361instance 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
0 commit comments