Skip to content

Commit 3d9121c

Browse files
committed
Expr.Types: org: mv TH instances to their types
This should ideally align TH inference & would help keep the code properly structured & currently going to help me to understand what is going on with TH inference in GHC 9.0.
1 parent 737e575 commit 3d9121c

File tree

1 file changed

+31
-35
lines changed

1 file changed

+31
-35
lines changed

src/Nix/Expr/Types.hs

Lines changed: 31 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,11 @@ data Params r
146146
instance IsString (Params r) where
147147
fromString = Param . fromString
148148

149+
$(deriveShow1 ''Params)
150+
$(deriveRead1 ''Params)
151+
$(deriveEq1 ''Params)
152+
$(deriveOrd1 ''Params)
153+
149154
-- *** Lens traversals
150155

151156
$(makeTraversals ''Params)
@@ -179,6 +184,17 @@ instance Hashable2 Antiquoted where
179184
liftHashWithSalt2 _ _ salt EscapedNewline = salt `hashWithSalt` (1 :: Int)
180185
liftHashWithSalt2 _ hb salt (Antiquoted b) = hb (salt `hashWithSalt` (2 :: Int)) b
181186

187+
$(deriveShow1 ''Antiquoted)
188+
$(deriveShow2 ''Antiquoted)
189+
$(deriveRead1 ''Antiquoted)
190+
$(deriveRead2 ''Antiquoted)
191+
$(deriveEq1 ''Antiquoted)
192+
$(deriveEq2 ''Antiquoted)
193+
$(deriveOrd1 ''Antiquoted)
194+
$(deriveOrd2 ''Antiquoted)
195+
$(deriveJSON2 defaultOptions ''Antiquoted)
196+
197+
182198
-- *** Lens traversals
183199

184200
$(makeTraversals ''Antiquoted)
@@ -219,6 +235,11 @@ instance IsString (NString r) where
219235
fromString "" = DoubleQuoted mempty
220236
fromString string = DoubleQuoted [Plain $ toText string]
221237

238+
$(deriveShow1 ''NString)
239+
$(deriveRead1 ''NString)
240+
$(deriveEq1 ''NString)
241+
$(deriveOrd1 ''NString)
242+
222243
-- *** Lens traversals
223244

224245
$(makeTraversals ''NString)
@@ -368,6 +389,11 @@ data Binding r
368389
, Show, Hashable, Hashable1
369390
)
370391

392+
$(deriveShow1 ''Binding)
393+
$(deriveEq1 ''Binding)
394+
$(deriveOrd1 ''Binding)
395+
--x $(deriveJSON1 defaultOptions ''Binding)
396+
371397
-- *** Lens traversals
372398

373399
$(makeTraversals ''Binding)
@@ -533,6 +559,11 @@ data NExprF r
533559
)
534560

535561

562+
$(deriveShow1 ''NExprF)
563+
$(deriveEq1 ''NExprF)
564+
$(deriveOrd1 ''NExprF)
565+
--x $(deriveJSON1 defaultOptions ''NExprF)
566+
536567
-- *** Lens traversals
537568

538569
$(makeTraversals ''NExprF)
@@ -572,41 +603,6 @@ instance TH.Lift NExpr where
572603
#endif
573604

574605

575-
-- ** Additional instances
576-
577-
$(deriveShow1 ''Params)
578-
$(deriveShow1 ''Antiquoted)
579-
$(deriveShow2 ''Antiquoted)
580-
$(deriveShow1 ''NString)
581-
$(deriveShow1 ''Binding)
582-
$(deriveShow1 ''NExprF)
583-
584-
$(deriveRead1 ''Params)
585-
$(deriveRead1 ''Antiquoted)
586-
$(deriveRead2 ''Antiquoted)
587-
$(deriveRead1 ''NString)
588-
589-
$(deriveEq1 ''Params)
590-
$(deriveEq1 ''Antiquoted)
591-
$(deriveEq2 ''Antiquoted)
592-
$(deriveEq1 ''NString)
593-
$(deriveEq1 ''Binding)
594-
$(deriveEq1 ''NExprF)
595-
596-
$(deriveOrd1 ''Params)
597-
$(deriveOrd1 ''Antiquoted)
598-
$(deriveOrd2 ''Antiquoted)
599-
$(deriveOrd1 ''NString)
600-
$(deriveOrd1 ''Binding)
601-
$(deriveOrd1 ''NExprF)
602-
603-
$(deriveJSON2 defaultOptions ''Antiquoted)
604-
--x $(deriveJSON1 defaultOptions ''Binding)
605-
--x $(deriveJSON1 defaultOptions ''NExprF)
606-
607-
--x $(makeLenses ''Fix)
608-
609-
610606
-- ** Methods
611607

612608
hashAt :: VarName -> Lens' (AttrSet v) (Maybe v)

0 commit comments

Comments
 (0)