Skip to content

Commit

Permalink
Eval: demand(F->)
Browse files Browse the repository at this point in the history
  • Loading branch information
Anton-Latukha committed Mar 4, 2021
1 parent 6fb7c98 commit 7712fc4
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/Nix/Eval.hs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ type MonadNixEval v m
= ( MonadEval v m
, Scoped v m
, MonadValue v m
, MonadValueF v m
, MonadFix m
, ToValue Bool m v
, ToValue [v] m v
Expand Down Expand Up @@ -118,7 +117,7 @@ eval (NSym var ) = do
mres <- lookupVar var
maybe
(freeVariable var)
(demandF (evaledSym var))
(evaledSym var <=< demand)
mres

eval (NConstant x ) = evalConstant x
Expand Down Expand Up @@ -178,7 +177,7 @@ evalWithAttrSet aset body = do
-- computed once.
scope <- currentScopes :: m (Scopes m v)
s <- defer $ withScopes scope aset
let s' = demandF (fmap fst . fromValue @(AttrSet v, AttrSet SourcePos)) s
let s' = (fmap fst . fromValue @(AttrSet v, AttrSet SourcePos)) =<< demand s
pushWeakScope s' body

attrSetAlter
Expand All @@ -199,7 +198,7 @@ attrSetAlter (k : ks) pos m p val =
(\x ->
do
(st, sp) <- fromValue @(AttrSet v, AttrSet SourcePos) =<< x
recurse (demandF pure <$> st) sp
recurse ((pure <=< demand) <$> st) sp
)
(M.lookup k m)
)
Expand Down Expand Up @@ -270,7 +269,7 @@ evalBinds recursive binds = do
finalValue >>= fromValue >>= \(o', p') ->
-- jww (2018-05-09): What to do with the key position here?
pure $ fmap
(\(k, v) -> ([k], fromMaybe pos (M.lookup k p'), demandF pure v))
(\(k, v) -> ([k], fromMaybe pos (M.lookup k p'), pure =<< demand v))
(M.toList o')

go _ (NamedVar pathExpr finalValue pos) = do
Expand Down Expand Up @@ -315,7 +314,7 @@ evalBinds recursive binds = do
ms
maybe
(attrMissing (key :| []) Nothing)
(demandF pure)
(pure <=< demand)
mv
)
)
Expand Down Expand Up @@ -350,8 +349,8 @@ evalSelect aset attr = do
extract x path@(k :| ks) = fromValueMay x >>= \case
Just (s :: AttrSet v, p :: AttrSet SourcePos)
| Just t <- M.lookup k s -> case ks of
[] -> pure $ pure $ demandF pure t
y : ys -> demandF (extract ?? (y :| ys)) t
[] -> pure $ pure $ pure =<< demand t
y : ys -> (extract ?? (y :| ys)) =<< demand t
| otherwise -> Left . (, path) <$> toValue (s, p)
Nothing -> pure $ Left (x, path)

Expand Down

0 comments on commit 7712fc4

Please sign in to comment.