Skip to content

Commit 996f91b

Browse files
committed
treewide: Expr.Value.NValieF: flip NVSetF
The proper argument order.
1 parent e168bc9 commit 996f91b

File tree

13 files changed

+45
-54
lines changed

13 files changed

+45
-54
lines changed

main/Main.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ main' opts@Options{..} = runWithBasicEffectsIO opts execContentsFilesOrRepl
248248
maybe
249249
pass
250250
(\case
251-
NVSet s' _ -> go (path <> ".") s'
251+
NVSet _ s' -> go (path <> ".") s'
252252
_ -> pass
253253
)
254254
mv

main/Repl.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ exec update source = do
225225

226226
-- If the result value is a set, update our context with it
227227
case val of
228-
NVSet xs _ -> put st { replCtx = xs <> replCtx st }
228+
NVSet _ xs -> put st { replCtx = xs <> replCtx st }
229229
_ -> pass
230230

231231
pure $ pure val
@@ -410,7 +410,7 @@ completeFunc reversedPrev word
410410
do
411411
s <- get
412412
let contextKeys = Data.HashMap.Lazy.keys (replCtx s)
413-
(Just (NVSet builtins _)) = Data.HashMap.Lazy.lookup "builtins" (replCtx s)
413+
(Just (NVSet _ builtins)) = Data.HashMap.Lazy.lookup "builtins" (replCtx s)
414414
shortBuiltins = Data.HashMap.Lazy.keys builtins
415415

416416
pure $ listCompletion $ toString <$>
@@ -447,7 +447,7 @@ completeFunc reversedPrev word
447447
(Data.HashMap.Lazy.lookup (coerce f) m)
448448
in
449449
case val of
450-
NVSet xs _ -> withMap (Data.HashMap.Lazy.mapKeys coerce xs)
450+
NVSet _ xs -> withMap (Data.HashMap.Lazy.mapKeys coerce xs)
451451
_ -> stub
452452

453453
-- | HelpOption inspired by Dhall Repl

src/Nix.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ processResult h val = do
149149
v' <- demand v
150150
case (k, v') of
151151
(Text.decimal . coerce -> Right (n,""), NVList xs) -> processKeys ks $ xs !! n
152-
(_, NVSet xs _) ->
152+
(_, NVSet _ xs) ->
153153
maybe
154154
(errorWithoutStackTrace $ "Set does not contain key ''" <> show k <> "''.")
155155
(processKeys ks)

src/Nix/Builtins.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ unsafeGetAttrPosNix nvX nvY =
472472
y <- demand nvY
473473

474474
case (x, y) of
475-
(NVStr ns, NVSet _ apos) ->
475+
(NVStr ns, NVSet apos _) ->
476476
maybe
477477
(pure nvNull)
478478
toValue
@@ -1607,7 +1607,7 @@ fetchurlNix
16071607
:: forall e t f m . MonadNix e t f m => NValue t f m -> m (NValue t f m)
16081608
fetchurlNix =
16091609
(\case
1610-
NVSet s _ -> go (M.lookup "sha256" s) =<< demand =<< attrsetGet "url" s
1610+
NVSet _ s -> go (M.lookup "sha256" s) =<< demand =<< attrsetGet "url" s
16111611
v@NVStr{} -> go Nothing v
16121612
v -> throwError $ ErrorCall $ "builtins.fetchurl: Expected URI or set, got " <> show v
16131613
) <=< demand
@@ -1697,7 +1697,7 @@ appendContextNix tx ty =
16971697
y <- demand ty
16981698

16991699
case (x, y) of
1700-
(NVStr ns, NVSet attrs _) ->
1700+
(NVStr ns, NVSet _ attrs) ->
17011701
do
17021702
newContextValues <- traverse getPathNOuts attrs
17031703

@@ -1711,7 +1711,7 @@ appendContextNix tx ty =
17111711
x <- demand tx
17121712

17131713
case x of
1714-
NVSet attrs _ ->
1714+
NVSet _ attrs->
17151715
do
17161716
-- TODO: Fail for unexpected keys.
17171717

src/Nix/Convert.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ instance ( Convertible e t f m
197197
NVPath' p ->
198198
(\path -> pure $ makeNixStringWithSingletonContext path (StringContext path DirectPath)) . fromString . coerce <$>
199199
addPath p
200-
NVSet' s _ ->
200+
NVSet' _ s ->
201201
maybe
202202
stub
203203
fromValueMay
@@ -229,7 +229,7 @@ instance ( Convertible e t f m
229229
\case
230230
NVPath' p -> pure $ pure $ coerce p
231231
NVStr' ns -> pure $ coerce . toString <$> getStringNoContext ns
232-
NVSet' s _ ->
232+
NVSet' _ s ->
233233
maybe
234234
(pure Nothing)
235235
(fromValueMay @Path)
@@ -267,7 +267,7 @@ instance Convertible e t f m
267267
fromValueMay =
268268
pure .
269269
\case
270-
NVSet' s _ -> pure s
270+
NVSet' _ s -> pure s
271271
_ -> mempty
272272

273273
fromValue = fromMayToValue TSet
@@ -279,7 +279,7 @@ instance ( Convertible e t f m
279279

280280
fromValueMay =
281281
\case
282-
Deeper (NVSet' s _) -> sequence <$> traverse fromValueMay s
282+
Deeper (NVSet' _ s) -> sequence <$> traverse fromValueMay s
283283
_ -> stub
284284

285285
fromValue = fromMayToDeeperValue TSet
@@ -291,7 +291,7 @@ instance Convertible e t f m
291291
fromValueMay =
292292
pure .
293293
\case
294-
NVSet' s p -> pure (s, p)
294+
NVSet' p s -> pure (s, p)
295295
_ -> mempty
296296

297297
fromValue = fromMayToValue TSet
@@ -304,7 +304,7 @@ instance ( Convertible e t f m
304304

305305
fromValueMay =
306306
\case
307-
Deeper (NVSet' s p) -> fmap (, p) . sequence <$> traverse fromValueMay s
307+
Deeper (NVSet' p s) -> fmap (, p) . sequence <$> traverse fromValueMay s
308308
_ -> stub
309309

310310
fromValue = fromMayToDeeperValue TSet

src/Nix/Effects/Basic.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ fetchTarball
179179
:: forall e t f m . MonadNix e t f m => NValue t f m -> m (NValue t f m)
180180
fetchTarball =
181181
\case
182-
NVSet s _ ->
182+
NVSet _ s ->
183183
maybe
184184
(throwError $ ErrorCall "builtins.fetchTarball: Missing url attribute")
185185
(go (M.lookup "sha256" s) <=< demand)

src/Nix/Exec.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ callFunc fun arg =
300300
do
301301
span <- currentPos
302302
withFrame Info ((Calling @m @(NValue t f m)) (coerce name) span) $ f arg -- Is this cool?
303-
(NVSet m _) | Just f <- M.lookup "__functor" m ->
303+
(NVSet _ m) | Just f <- M.lookup "__functor" m ->
304304
(`callFunc` arg) =<< (`callFunc` fun') =<< demand f
305305
_x -> throwError $ ErrorCall $ "Attempt to call non-function: " <> show _x
306306

@@ -403,9 +403,9 @@ execBinaryOpForced scope span op lval rval = case op of
403403

404404
NUpdate ->
405405
case (lval, rval) of
406-
(NVSet ls lp, NVSet rs rp) -> pure $ nvSetP prov (rp <> lp) (rs <> ls)
407-
(NVSet ls lp, NVConstant NNull) -> pure $ nvSetP prov lp ls
408-
(NVConstant NNull, NVSet rs rp) -> pure $ nvSetP prov rp rs
406+
(NVSet lp ls, NVSet rp rs) -> pure $ nvSetP prov (rp <> lp) (rs <> ls)
407+
(NVSet lp ls, NVConstant NNull) -> pure $ nvSetP prov lp ls
408+
(NVConstant NNull, NVSet rp rs) -> pure $ nvSetP prov rp rs
409409
_ -> unsupportedTypes
410410

411411
NPlus ->

src/Nix/Json.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ nvalueToJSON = \case
3636
NVConstant NNull -> pure A.Null
3737
NVStr ns -> A.toJSON <$> extractNixString ns
3838
NVList l -> A.Array . V.fromList <$> traverse intoJson l
39-
NVSet m _ ->
39+
NVSet _ m ->
4040
maybe
4141
(A.Object <$> traverse intoJson (HM.mapKeys (coerce @VarName @Text) m))
4242
intoJson

src/Nix/Pretty.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ valueToExpr = iterNValueByDiscardWith thk (Fix . phi)
321321
phi (NVConstant' a ) = NConstant a
322322
phi (NVStr' ns ) = NStr $ DoubleQuoted [Plain (stringIgnoreContext ns)]
323323
phi (NVList' l ) = NList l
324-
phi (NVSet' s p) = NSet NonRecursive
324+
phi (NVSet' p s) = NSet NonRecursive
325325
[ NamedVar (StaticKey k :| mempty) v (fromMaybe nullPos (M.lookup (coerce k) p))
326326
| (k, v) <- toList s
327327
]
@@ -386,7 +386,7 @@ printNix = iterNValueByDiscardWith thk phi
386386
phi (NVConstant' a ) = toString $ atomText a
387387
phi (NVStr' ns) = show $ stringIgnoreContext ns
388388
phi (NVList' l ) = toString $ "[ " <> unwords (fmap toText l) <> " ]"
389-
phi (NVSet' s _) =
389+
phi (NVSet' _ s) =
390390
"{ " <>
391391
concat
392392
[ check (toString k) <> " = " <> v <> "; "

src/Nix/String/Coerce.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ coerceToString call ctsm clevel = go
8585
(fmap storePathToNixString . addPath)
8686
(ctsm == CopyToStore)
8787
p
88-
v@(NVSet s _) ->
88+
v@(NVSet _ s) ->
8989
maybe
9090
(maybe
9191
(err v)

0 commit comments

Comments
 (0)