Skip to content

Commit 6e23add

Browse files
committed
Builtins: Eval: evalBinds: (maybe -> =<<)
1 parent 78771ce commit 6e23add

File tree

2 files changed

+32
-27
lines changed

2 files changed

+32
-27
lines changed

src/Nix/Builtins.hs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,11 @@ withNixContext mpath action =
120120
)
121121
mpath
122122

123-
builtins :: (MonadNix e t f m, Scoped (NValue t f m) m)
124-
=> m (Scopes m (NValue t f m))
123+
builtins
124+
:: ( MonadNix e t f m
125+
, Scoped (NValue t f m) m
126+
)
127+
=> m (Scopes m (NValue t f m))
125128
builtins =
126129
do
127130
ref <- defer $ nvSet mempty <$> buildMap

src/Nix/Eval.hs

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -360,26 +360,27 @@ evalBinds recursive binds =
360360
:: NKeyName (m v)
361361
-> m (Maybe ([Text], SourcePos, m v))
362362
processScope nkeyname =
363-
maybe
364-
Nothing
365-
(\ key -> pure
366-
([key]
367-
, pos
368-
, maybe
369-
(attrMissing (key :| []) Nothing)
370-
(pure <=< demand)
371-
=<< maybe
372-
(withScopes scope $ lookupVar key)
373-
(\ s ->
374-
do
375-
(attrset, _) <- fromValue @(AttrSet v, AttrSet SourcePos) =<< s
376-
377-
clearScopes @v $ pushScope attrset $ lookupVar key
378-
)
379-
ms
380-
)
381-
)
382-
<$> evalSetterKeyName nkeyname
363+
(\ mkey ->
364+
do
365+
key <- mkey
366+
pure
367+
([key]
368+
, pos
369+
, maybe
370+
(attrMissing (key :| []) Nothing)
371+
(pure <=< demand)
372+
=<< maybe
373+
(withScopes scope $ lookupVar key)
374+
(\ s ->
375+
do
376+
(attrset, _) <- fromValue @(AttrSet v, AttrSet SourcePos) =<< s
377+
378+
clearScopes @v $ pushScope attrset $ lookupVar key
379+
)
380+
ms
381+
)
382+
) <$>
383+
evalSetterKeyName nkeyname
383384

384385
moveOverridesLast = uncurry (<>) . partition
385386
(\case
@@ -435,10 +436,11 @@ evalSetterKeyName
435436
:: (MonadEval v m, FromValue NixString m v)
436437
=> NKeyName (m v)
437438
-> m (Maybe Text)
438-
evalSetterKeyName = \case
439-
StaticKey k -> pure (pure k)
440-
DynamicKey k ->
441-
((pure . stringIgnoreContext) `ifJust`) <$> runAntiquoted "\n" assembleString (fromValueMay =<<) k
439+
evalSetterKeyName =
440+
\case
441+
StaticKey k -> pure (pure k)
442+
DynamicKey k ->
443+
((pure . stringIgnoreContext) `ifJust`) <$> runAntiquoted "\n" assembleString (fromValueMay =<<) k
442444

443445
assembleString
444446
:: forall v m
@@ -448,7 +450,7 @@ assembleString
448450
assembleString =
449451
fromParts .
450452
\case
451-
Indented _ parts -> parts
453+
Indented _ parts -> parts
452454
DoubleQuoted parts -> parts
453455
where
454456
fromParts = fmap (fmap mconcat . sequence) . traverse go

0 commit comments

Comments
 (0)