Skip to content

Commit 737e575

Browse files
committed
Expr.Types: org lens traversals
1 parent 91f430c commit 737e575

File tree

1 file changed

+34
-10
lines changed

1 file changed

+34
-10
lines changed

src/Nix/Expr/Types.hs

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

149+
-- *** Lens traversals
150+
151+
$(makeTraversals ''Params)
152+
149153

150154
-- ** @Antiquoted@
151155

@@ -175,6 +179,10 @@ instance Hashable2 Antiquoted where
175179
liftHashWithSalt2 _ _ salt EscapedNewline = salt `hashWithSalt` (1 :: Int)
176180
liftHashWithSalt2 _ hb salt (Antiquoted b) = hb (salt `hashWithSalt` (2 :: Int)) b
177181

182+
-- *** Lens traversals
183+
184+
$(makeTraversals ''Antiquoted)
185+
178186

179187
-- ** @NString@
180188

@@ -211,6 +219,10 @@ instance IsString (NString r) where
211219
fromString "" = DoubleQuoted mempty
212220
fromString string = DoubleQuoted [Plain $ toText string]
213221

222+
-- *** Lens traversals
223+
224+
$(makeTraversals ''NString)
225+
214226

215227
-- ** @NKeyName@
216228

@@ -306,6 +318,10 @@ instance Traversable NKeyName where
306318
DynamicKey EscapedNewline -> pure $ DynamicKey EscapedNewline
307319
StaticKey key -> pure $ StaticKey key
308320

321+
-- *** Lens traversals
322+
323+
$(makeTraversals ''NKeyName)
324+
309325

310326
-- ** @NAttrPath@
311327

@@ -352,6 +368,10 @@ data Binding r
352368
, Show, Hashable, Hashable1
353369
)
354370

371+
-- *** Lens traversals
372+
373+
$(makeTraversals ''Binding)
374+
355375

356376
-- ** @NRecordType@
357377

@@ -367,7 +387,7 @@ data NRecordType
367387
)
368388

369389

370-
-- ** @NUnaryOp
390+
-- ** @NUnaryOp@
371391

372392
-- | There are two unary operations: logical not and integer negation.
373393
data NUnaryOp
@@ -379,6 +399,10 @@ data NUnaryOp
379399
, Show, Read, Hashable
380400
)
381401

402+
-- *** Lens traversals
403+
404+
$(makeTraversals ''NUnaryOp)
405+
382406

383407
-- ** @NBinaryOp@
384408

@@ -408,6 +432,10 @@ data NBinaryOp
408432
, Show, Read, Hashable
409433
)
410434

435+
-- *** Lens traversals
436+
437+
$(makeTraversals ''NBinaryOp)
438+
411439

412440
-- ** @NExprF@ - Nix expressions, base functor
413441

@@ -505,6 +533,11 @@ data NExprF r
505533
)
506534

507535

536+
-- *** Lens traversals
537+
538+
$(makeTraversals ''NExprF)
539+
540+
508541
-- *** @NExpr@
509542

510543
-- | The monomorphic expression type is a fixed point of the polymorphic one.
@@ -571,15 +604,6 @@ $(deriveJSON2 defaultOptions ''Antiquoted)
571604
--x $(deriveJSON1 defaultOptions ''Binding)
572605
--x $(deriveJSON1 defaultOptions ''NExprF)
573606

574-
$(makeTraversals ''Params)
575-
$(makeTraversals ''Antiquoted)
576-
$(makeTraversals ''NString)
577-
$(makeTraversals ''NKeyName)
578-
$(makeTraversals ''Binding)
579-
$(makeTraversals ''NUnaryOp)
580-
$(makeTraversals ''NBinaryOp)
581-
$(makeTraversals ''NExprF)
582-
583607
--x $(makeLenses ''Fix)
584608

585609

0 commit comments

Comments
 (0)