Skip to content

Commit 6fd4a83

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 c1c5dee commit 6fd4a83

File tree

9 files changed

+47
-10
lines changed

9 files changed

+47
-10
lines changed

containers-tests/containers-tests.cabal

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

4346
common warnings
4447
ghc-options: -Werror=unused-top-binds

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: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,9 +355,13 @@ import Data.Data (Data(..), Constr, mkConstr, constrIndex,
355355
import qualified Data.Data as Data
356356
import GHC.Exts (build)
357357
import qualified GHC.Exts as GHCExts
358-
import Language.Haskell.TH.Syntax (Lift)
358+
# if __GLASGOW_HASKELL__ >= 914
359+
import Language.Haskell.TH.Lift (Lift(..))
360+
# else
361+
import Language.Haskell.TH.Syntax (Lift(..))
359362
-- See Note [ Template Haskell Dependencies ]
360363
import Language.Haskell.TH ()
364+
# endif
361365
#endif
362366
#if defined(__GLASGOW_HASKELL__) || defined(__MHS__)
363367
import Text.Read

containers/src/Data/IntSet/Internal.hs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,13 @@ import Data.Coerce (coerce)
226226

227227
#if __GLASGOW_HASKELL__
228228
import qualified GHC.Exts
229-
import Language.Haskell.TH.Syntax (Lift)
229+
# if __GLASGOW_HASKELL__ >= 914
230+
import Language.Haskell.TH.Lift (Lift(..))
231+
# else
232+
import Language.Haskell.TH.Syntax (Lift(..))
230233
-- See Note [ Template Haskell Dependencies ]
231234
import Language.Haskell.TH ()
235+
# endif
232236
#endif
233237

234238
import qualified Data.Foldable as Foldable

containers/src/Data/Map/Internal.hs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,9 +412,13 @@ import Utils.Containers.Internal.BitUtil (wordSize)
412412

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

containers/src/Data/Sequence/Internal.hs

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

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

containers/src/Data/Set/Internal.hs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,14 @@ import Text.Read ( readPrec, Read (..), Lexeme (..), parens, prec
252252
import GHC.Exts ( build, lazy )
253253
import qualified GHC.Exts as GHCExts
254254
import Data.Data
255-
import Language.Haskell.TH.Syntax (Lift)
255+
# if __GLASGOW_HASKELL__ >= 914
256+
import Language.Haskell.TH.Lift (Lift(..))
257+
# else
258+
import Language.Haskell.TH.Syntax (Lift(..))
256259
-- See Note [ Template Haskell Dependencies ]
257260
import Language.Haskell.TH ()
258-
import Data.Coerce (coerce)
261+
# endif
262+
import Data.Coerce
259263
#endif
260264

261265

containers/src/Data/Tree.hs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,13 @@ import Control.DeepSeq (NFData(rnf),NFData1(liftRnf))
7575
import Data.Data (Data)
7676
import GHC.Generics (Generic, Generic1)
7777
import qualified GHC.Exts
78-
import Language.Haskell.TH.Syntax (Lift)
78+
# if __GLASGOW_HASKELL__ >= 914
79+
import Language.Haskell.TH.Lift (Lift(..))
80+
# else
81+
import Language.Haskell.TH.Syntax (Lift(..))
7982
-- See Note [ Template Haskell Dependencies ]
8083
import Language.Haskell.TH ()
84+
# endif
8185
#endif
8286

8387
import Control.Monad.Zip (MonadZip (..))

0 commit comments

Comments
 (0)