Skip to content

Commit 7712fc4

Browse files
committed
Eval: demand(F->)
1 parent 6fb7c98 commit 7712fc4

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/Nix/Eval.hs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ type MonadNixEval v m
8282
= ( MonadEval v m
8383
, Scoped v m
8484
, MonadValue v m
85-
, MonadValueF v m
8685
, MonadFix m
8786
, ToValue Bool m v
8887
, ToValue [v] m v
@@ -118,7 +117,7 @@ eval (NSym var ) = do
118117
mres <- lookupVar var
119118
maybe
120119
(freeVariable var)
121-
(demandF (evaledSym var))
120+
(evaledSym var <=< demand)
122121
mres
123122

124123
eval (NConstant x ) = evalConstant x
@@ -178,7 +177,7 @@ evalWithAttrSet aset body = do
178177
-- computed once.
179178
scope <- currentScopes :: m (Scopes m v)
180179
s <- defer $ withScopes scope aset
181-
let s' = demandF (fmap fst . fromValue @(AttrSet v, AttrSet SourcePos)) s
180+
let s' = (fmap fst . fromValue @(AttrSet v, AttrSet SourcePos)) =<< demand s
182181
pushWeakScope s' body
183182

184183
attrSetAlter
@@ -199,7 +198,7 @@ attrSetAlter (k : ks) pos m p val =
199198
(\x ->
200199
do
201200
(st, sp) <- fromValue @(AttrSet v, AttrSet SourcePos) =<< x
202-
recurse (demandF pure <$> st) sp
201+
recurse ((pure <=< demand) <$> st) sp
203202
)
204203
(M.lookup k m)
205204
)
@@ -270,7 +269,7 @@ evalBinds recursive binds = do
270269
finalValue >>= fromValue >>= \(o', p') ->
271270
-- jww (2018-05-09): What to do with the key position here?
272271
pure $ fmap
273-
(\(k, v) -> ([k], fromMaybe pos (M.lookup k p'), demandF pure v))
272+
(\(k, v) -> ([k], fromMaybe pos (M.lookup k p'), pure =<< demand v))
274273
(M.toList o')
275274

276275
go _ (NamedVar pathExpr finalValue pos) = do
@@ -315,7 +314,7 @@ evalBinds recursive binds = do
315314
ms
316315
maybe
317316
(attrMissing (key :| []) Nothing)
318-
(demandF pure)
317+
(pure <=< demand)
319318
mv
320319
)
321320
)
@@ -350,8 +349,8 @@ evalSelect aset attr = do
350349
extract x path@(k :| ks) = fromValueMay x >>= \case
351350
Just (s :: AttrSet v, p :: AttrSet SourcePos)
352351
| Just t <- M.lookup k s -> case ks of
353-
[] -> pure $ pure $ demandF pure t
354-
y : ys -> demandF (extract ?? (y :| ys)) t
352+
[] -> pure $ pure $ pure =<< demand t
353+
y : ys -> (extract ?? (y :| ys)) =<< demand t
355354
| otherwise -> Left . (, path) <$> toValue (s, p)
356355
Nothing -> pure $ Left (x, path)
357356

0 commit comments

Comments
 (0)