Skip to content

Commit cb23ca5

Browse files
authored
Allow template-haskell-2.16 (#1719)
This uses -XDeriveLift to address the missing liftTyped definitions.
1 parent b0175e7 commit cb23ca5

File tree

3 files changed

+12
-30
lines changed

3 files changed

+12
-30
lines changed

dhall/dhall.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ Library
477477
repline >= 0.2.1.0 && < 0.4 ,
478478
serialise >= 0.2.0.0 && < 0.3 ,
479479
scientific >= 0.3.0.0 && < 0.4 ,
480-
template-haskell >= 2.11.1.0 && < 2.16,
480+
template-haskell >= 2.11.1.0 && < 2.17,
481481
text >= 0.11.1.0 && < 1.3 ,
482482
text-manipulate >= 0.2.0.1 && < 0.3 ,
483483
th-lift-instances >= 0.1.13 && < 0.2 ,

dhall/src/Dhall/Map.hs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
{-# LANGUAGE DeriveAnyClass #-}
33
{-# LANGUAGE DeriveDataTypeable #-}
44
{-# LANGUAGE DeriveGeneric #-}
5+
{-# LANGUAGE DeriveLift #-}
56
{-# LANGUAGE DeriveTraversable #-}
67
{-# LANGUAGE RecordWildCards #-}
78
{-# LANGUAGE TypeFamilies #-}
@@ -80,7 +81,6 @@ import qualified Data.List
8081
import qualified Data.Map
8182
import qualified Data.Set
8283
import qualified GHC.Exts
83-
import qualified Language.Haskell.TH.Syntax as Syntax
8484
import qualified Prelude
8585

8686
{-| A `Map` that remembers the original ordering of keys
@@ -91,18 +91,12 @@ import qualified Prelude
9191
and also to improve performance
9292
-}
9393
data Map k v = Map (Data.Map.Map k v) (Keys k)
94-
deriving (Data, Generic, NFData)
95-
96-
instance (Data k, Data v, Lift k, Lift v, Ord k) => Lift (Map k v) where
97-
lift = Syntax.liftData
94+
deriving (Data, Generic, Lift, NFData)
9895

9996
data Keys a
10097
= Sorted
10198
| Original [a]
102-
deriving (Data, Generic, NFData)
103-
104-
instance (Data a, Lift a) => Lift (Keys a) where
105-
lift = Syntax.liftData
99+
deriving (Data, Generic, Lift, NFData)
106100

107101
instance (Ord k, Eq v) => Eq (Map k v) where
108102
m1 == m2 =

dhall/src/Dhall/Syntax.hs

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
{-# LANGUAGE DeriveAnyClass #-}
44
{-# LANGUAGE DeriveDataTypeable #-}
55
{-# LANGUAGE DeriveGeneric #-}
6+
{-# LANGUAGE DeriveLift #-}
67
{-# LANGUAGE DeriveTraversable #-}
78
{-# LANGUAGE LambdaCase #-}
89
{-# LANGUAGE OverloadedLists #-}
@@ -101,7 +102,6 @@ import qualified Data.Text
101102
import qualified Data.Text.Prettyprint.Doc as Pretty
102103
import qualified Dhall.Crypto
103104
import qualified Dhall.Optics as Optics
104-
import qualified Language.Haskell.TH.Syntax as Syntax
105105
import qualified Network.URI as URI
106106

107107
{-| Constants for a pure type system
@@ -124,10 +124,7 @@ import qualified Network.URI as URI
124124
Dhall is not a dependently typed language
125125
-}
126126
data Const = Type | Kind | Sort
127-
deriving (Show, Eq, Ord, Data, Bounded, Enum, Generic, NFData)
128-
129-
instance Lift Const where
130-
lift = Syntax.liftData
127+
deriving (Show, Eq, Ord, Data, Bounded, Enum, Generic, Lift, NFData)
131128

132129
instance Pretty Const where
133130
pretty = Pretty.unAnnotate . prettyConst
@@ -165,10 +162,7 @@ instance Pretty Const where
165162
appear as a numeric suffix.
166163
-}
167164
data Var = V Text !Int
168-
deriving (Data, Generic, Eq, Ord, Show, NFData)
169-
170-
instance Lift Var where
171-
lift = Syntax.liftData
165+
deriving (Data, Generic, Eq, Ord, Show, Lift, NFData)
172166

173167
instance IsString Var where
174168
fromString str = V (fromString str) 0
@@ -196,7 +190,7 @@ data Binding s a = Binding
196190
, annotation :: Maybe (Maybe s, Expr s a)
197191
, bindingSrc2 :: Maybe s
198192
, value :: Expr s a
199-
} deriving (Data, Eq, Foldable, Functor, Generic, NFData, Ord, Show, Traversable)
193+
} deriving (Data, Eq, Foldable, Functor, Generic, Lift, NFData, Ord, Show, Traversable)
200194

201195
instance Bifunctor Binding where
202196
first k (Binding src0 a src1 b src2 c) =
@@ -214,7 +208,7 @@ makeBinding name = Binding Nothing name Nothing Nothing Nothing
214208
-- | This wrapper around 'Prelude.Double' exists for its 'Eq' instance which is
215209
-- defined via the binary encoding of Dhall @Double@s.
216210
newtype DhallDouble = DhallDouble { getDhallDouble :: Double }
217-
deriving (Show, Data, NFData, Generic)
211+
deriving (Show, Data, Lift, NFData, Generic)
218212

219213
-- | This instance satisfies all the customary 'Eq' laws except substitutivity.
220214
--
@@ -245,10 +239,7 @@ instance Ord DhallDouble where
245239

246240
-- | The body of an interpolated @Text@ literal
247241
data Chunks s a = Chunks [(Text, Expr s a)] Text
248-
deriving (Functor, Foldable, Generic, Traversable, Show, Eq, Ord, Data, NFData)
249-
250-
instance (Lift s, Lift a, Data s, Data a) => Lift (Chunks s a) where
251-
lift = Syntax.liftData
242+
deriving (Functor, Foldable, Generic, Traversable, Show, Eq, Ord, Data, Lift, NFData)
252243

253244
instance Data.Semigroup.Semigroup (Chunks s a) where
254245
Chunks xysL zL <> Chunks [] zR =
@@ -273,7 +264,7 @@ data PreferAnnotation s a
273264
| PreferFromWith (Expr s a)
274265
-- ^ Stores the original @with@ expression
275266
| PreferFromCompletion
276-
deriving (Data, Eq, Foldable, Functor, Generic, NFData, Ord, Show, Traversable)
267+
deriving (Data, Eq, Foldable, Functor, Generic, Lift, NFData, Ord, Show, Traversable)
277268

278269
instance Bifunctor PreferAnnotation where
279270
first _ PreferFromSource = PreferFromSource
@@ -480,7 +471,7 @@ data Expr s a
480471
| ImportAlt (Expr s a) (Expr s a)
481472
-- | > Embed import ~ import
482473
| Embed a
483-
deriving (Foldable, Generic, Traversable, Show, Data, NFData)
474+
deriving (Foldable, Generic, Traversable, Show, Data, Lift, NFData)
484475
-- NB: If you add a constructor to Expr, please also update the Arbitrary
485476
-- instance in Dhall.Test.QuickCheck.
486477

@@ -497,9 +488,6 @@ deriving instance (Eq s, Eq a) => Eq (Expr s a)
497488
-- | Note that this 'Ord' instance inherits `DhallDouble`'s defects.
498489
deriving instance (Ord s, Ord a) => Ord (Expr s a)
499490

500-
instance (Lift s, Lift a, Data s, Data a) => Lift (Expr s a) where
501-
lift = Syntax.liftData
502-
503491
-- This instance is hand-written due to the fact that deriving
504492
-- it does not give us an INLINABLE pragma. We annotate this fmap
505493
-- implementation with this pragma below to allow GHC to, possibly,

0 commit comments

Comments
 (0)