Skip to content

Commit cdcd82c

Browse files
authored
refactor demand' with new style (#876)
1 parent ac17af6 commit cdcd82c

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

src/Nix/Effects/Derivation.hs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -318,18 +318,13 @@ buildDerivationWithContext drvAttrs = do
318318
mHash
319319

320320
-- filter out null values if needed.
321-
attrs <-
322-
bool
323-
(pure drvAttrs)
324-
(M.mapMaybe id <$> forM drvAttrs
325-
(demandF'
326-
(pure . \case
327-
NVConstant NNull -> Nothing
328-
value -> pure value
329-
)
330-
)
321+
attrs <- lift $ if not ignoreNulls
322+
then pure drvAttrs
323+
else M.mapMaybe id <$> forM drvAttrs (
324+
demand >=> \case
325+
NVConstant NNull -> pure Nothing
326+
value -> pure $ Just value
331327
)
332-
ignoreNulls
333328

334329
env <- if useJson
335330
then do
@@ -350,9 +345,6 @@ buildDerivationWithContext drvAttrs = do
350345

351346
-- common functions, lifted to WithStringContextT
352347

353-
demandF' :: (NValue t f m -> WithStringContextT m a) -> NValue t f m -> WithStringContextT m a
354-
demandF' f v = join $ lift $ f <$> demand v
355-
356348
fromValue' :: (FromValue a m (NValue' t f m (NValue t f m)), MonadNix e t f m) => NValue t f m -> WithStringContextT m a
357349
fromValue' = lift . fromValue
358350

0 commit comments

Comments
 (0)