Skip to content

Commit a86140e

Browse files
committed
Reduce: reduce: refactor
1 parent 9af8917 commit a86140e

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/Nix/Reduce.hs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -218,13 +218,20 @@ reduce base@(NSelect_ _ _ attrs _)
218218

219219
-- | Reduce a set by inlining its binds outside of the set
220220
-- if none of the binds inherit the super set.
221-
reduce e@(NSet_ ann NNonRecursive binds) = do
222-
let usesInherit = flip any binds $ \case
223-
Inherit{} -> True
224-
_ -> False
225-
if usesInherit
226-
then clearScopes @NExprLoc $ Fix . NSet_ ann NNonRecursive <$> traverse sequence binds
227-
else Fix <$> sequence e
221+
reduce e@(NSet_ ann NNonRecursive binds) =
222+
do
223+
let
224+
usesInherit =
225+
any
226+
(\case
227+
Inherit{} -> True
228+
_ -> False
229+
)
230+
binds
231+
232+
if usesInherit
233+
then clearScopes @NExprLoc $ Fix . NSet_ ann NNonRecursive <$> traverse sequence binds
234+
else Fix <$> sequence e
228235

229236
-- Encountering a 'rec set' construction eliminates any hope of inlining
230237
-- definitions.

0 commit comments

Comments
 (0)