Skip to content

Commit 4206889

Browse files
committed
Use template-haskell-lift for GHC>=9.14
This new boot library should be more stable than template-haskell and should eventually allow us to remove much of the CPP around TH. It will also make it easier for end-users to reinstall template-haskell as it will no longer be used by any boot libraries
1 parent e7b1b72 commit 4206889

File tree

11 files changed

+52
-6
lines changed

11 files changed

+52
-6
lines changed

containers-tests/containers-tests.cabal

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ common deps
3838
array >=0.4.0.0
3939
, base >=4.10 && <5
4040
, deepseq >= 1.4.3.0 && < 1.6
41-
, template-haskell
41+
42+
if impl(ghc >= 9.14)
43+
build-depends: template-haskell-lift >= 0.1 && <0.2
44+
elif impl(ghc)
45+
build-depends: template-haskell
4246

4347
common warnings
4448
ghc-options:

containers-tests/tests/seq-properties.hs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,18 @@ import Control.DeepSeq (deepseq)
4646
import Control.Monad.Fix (MonadFix (..))
4747
import Test.Tasty.HUnit
4848
import Test.ChasingBottoms.IsBottom (isBottom)
49+
#if __GLASGOW_HASKELL__ >= 914
50+
import qualified Language.Haskell.TH.Lift as TH
51+
#else
4952
import qualified Language.Haskell.TH.Syntax as TH
53+
#endif
5054

5155
import Utils.Strictness (Bot(..), Func2, applyFunc2)
5256

5357
main :: IO ()
5458
main = defaultMain $ testGroup "seq-properties"
5559
[ test_lift
56-
#if MIN_VERSION_template_haskell(2,16,0)
60+
#if __GLASGOW_HASKELL__ >= 810
5761
, test_liftTyped
5862
#endif
5963
, testProperty "fmap" prop_fmap
@@ -987,7 +991,7 @@ test_lift = testCase "lift" $ do
987991
(mempty :: Seq Int) @=? $([| $(TH.lift (fromList [] :: Seq Integer)) |])
988992
fromList [1..3 :: Int] @=? $([| $(TH.lift (fromList [1..3 :: Integer])) |])
989993

990-
#if MIN_VERSION_template_haskell(2,16,0)
994+
#if __GLASGOW_HASKELL__ >= 810
991995
test_liftTyped :: TestTree
992996
test_liftTyped = testCase "liftTyped" $ do
993997
(mempty :: Seq Int) @=? $$([|| $$(TH.liftTyped (fromList [])) ||])

containers/containers.cabal

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,12 @@ Library
4242
base >= 4.10 && < 5
4343
, array >= 0.4.0.0
4444
, deepseq >= 1.4.3.0 && < 1.6
45-
if impl(ghc)
45+
-- template-haskell-lift was added as a boot library in GHC-9.14
46+
-- once we no longer wish to backport releases to older major releases,
47+
-- this conditional can be dropped
48+
if impl(ghc >= 9.14)
49+
build-depends: template-haskell-lift >= 0.1 && <0.2
50+
elif impl(ghc)
4651
build-depends: template-haskell
4752
hs-source-dirs: src
4853
ghc-options: -O2 -Wall

containers/src/Data/Graph.hs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,13 @@ import Data.Semigroup (Semigroup (..))
143143
#ifdef __GLASGOW_HASKELL__
144144
import GHC.Generics (Generic, Generic1)
145145
import Data.Data (Data)
146+
# if __GLASGOW_HASKELL__ >= 914
147+
import Language.Haskell.TH.Lift (Lift)
148+
# else
146149
import Language.Haskell.TH.Syntax (Lift(..))
147150
-- See Note [ Template Haskell Dependencies ]
148151
import Language.Haskell.TH ()
152+
# endif
149153
#endif
150154

151155
-- Make sure we don't use Integer by mistake.
@@ -191,7 +195,7 @@ deriving instance Generic1 SCC
191195
deriving instance Generic (SCC vertex)
192196

193197
-- There is no instance Lift (NonEmpty v) before template-haskell-2.15.
194-
#if MIN_VERSION_template_haskell(2,15,0)
198+
#if __GLASGOW_HASKELL__ > 808
195199
-- | @since 0.6.6
196200
deriving instance Lift vertex => Lift (SCC vertex)
197201
#else

containers/src/Data/IntMap/Internal.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,9 +358,13 @@ import Data.Data (Data(..), Constr, mkConstr, constrIndex,
358358
import qualified Data.Data as Data
359359
import GHC.Exts (build)
360360
import qualified GHC.Exts as GHCExts
361+
# if __GLASGOW_HASKELL__ >= 914
362+
import Language.Haskell.TH.Lift (Lift)
363+
# else
361364
import Language.Haskell.TH.Syntax (Lift)
362365
-- See Note [ Template Haskell Dependencies ]
363366
import Language.Haskell.TH ()
367+
# endif
364368
#endif
365369
#if defined(__GLASGOW_HASKELL__) || defined(__MHS__)
366370
import Text.Read

containers/src/Data/IntSet/Internal.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,13 @@ import Data.Coerce (coerce)
230230

231231
#if __GLASGOW_HASKELL__
232232
import qualified GHC.Exts
233+
# if __GLASGOW_HASKELL__ >= 914
234+
import Language.Haskell.TH.Lift (Lift)
235+
# else
233236
import Language.Haskell.TH.Syntax (Lift)
234237
-- See Note [ Template Haskell Dependencies ]
235238
import Language.Haskell.TH ()
239+
# endif
236240
#endif
237241

238242
import qualified Data.Foldable as Foldable

containers/src/Data/IntSet/Internal/IntTreeCommons.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,13 @@ import Data.Bits (Bits(..), countLeadingZeros)
4444
import Utils.Containers.Internal.BitUtil (iShiftRL)
4545

4646
#ifdef __GLASGOW_HASKELL__
47+
# if __GLASGOW_HASKELL__ >= 914
48+
import Language.Haskell.TH.Lift (Lift)
49+
# else
4750
import Language.Haskell.TH.Syntax (Lift)
4851
-- See Note [ Template Haskell Dependencies ]
4952
import Language.Haskell.TH ()
53+
# endif
5054
#endif
5155

5256

containers/src/Data/Map/Internal.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,9 +413,13 @@ import Utils.Containers.Internal.BitUtil (wordSize)
413413

414414
#if __GLASGOW_HASKELL__
415415
import GHC.Exts (build, lazy)
416+
# if __GLASGOW_HASKELL__ >= 914
417+
import Language.Haskell.TH.Lift (Lift)
418+
# else
416419
import Language.Haskell.TH.Syntax (Lift)
417420
-- See Note [ Template Haskell Dependencies ]
418421
import Language.Haskell.TH ()
422+
# endif
419423
# ifdef USE_MAGIC_PROXY
420424
import GHC.Exts (Proxy#, proxy# )
421425
# endif

containers/src/Data/Sequence/Internal.hs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,13 @@ import Text.Read (Lexeme(Ident), lexP, parens, prec,
214214
import GHC.Exts (build)
215215
import Data.Data
216216
import Data.String (IsString(..))
217+
# if __GLASGOW_HASKELL__ >= 914
218+
import qualified Language.Haskell.TH.Lift as TH
219+
# else
217220
import qualified Language.Haskell.TH.Syntax as TH
218221
-- See Note [ Template Haskell Dependencies ]
219222
import Language.Haskell.TH ()
223+
# endif
220224
import GHC.Generics (Generic, Generic1)
221225

222226
-- Array stuff, with GHC.Arr on GHC
@@ -331,7 +335,8 @@ newtype Seq a = Seq (FingerTree (Elem a))
331335
#ifdef __GLASGOW_HASKELL__
332336
-- | @since 0.6.6
333337
instance TH.Lift a => TH.Lift (Seq a) where
334-
# if MIN_VERSION_template_haskell(2,16,0)
338+
-- template-haskell >= 2.16
339+
# if __GLASGOW_HASKELL__ >= 810
335340
liftTyped t = [|| coerceFT z ||]
336341
# else
337342
lift t = [| coerceFT z |]

containers/src/Data/Set/Internal.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,13 @@ import Text.Read ( readPrec, Read (..), Lexeme (..), parens, prec
255255
import GHC.Exts ( build, lazy )
256256
import qualified GHC.Exts as GHCExts
257257
import Data.Data
258+
# if __GLASGOW_HASKELL__ >= 914
259+
import Language.Haskell.TH.Lift (Lift)
260+
# else
258261
import Language.Haskell.TH.Syntax (Lift)
259262
-- See Note [ Template Haskell Dependencies ]
260263
import Language.Haskell.TH ()
264+
# endif
261265
import Data.Coerce (coerce)
262266
#endif
263267

0 commit comments

Comments
 (0)