Skip to content

Commit a6a4826

Browse files
committed
Eval: add fun evalContent
1 parent 1bddd93 commit a6a4826

File tree

6 files changed

+24
-11
lines changed

6 files changed

+24
-11
lines changed

ChangeLog.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11

22
# ChangeLog
33

4+
## [(diff)](https://github.com/haskell-nix/hnix/compare/0.13.1...master#files_bucket) WIP
5+
6+
* Additional:
7+
8+
* `Nix.Eval`:
9+
* added fun
10+
* `evalContent`
11+
412
### [(diff)](https://github.com/haskell-nix/hnix/compare/0.13.0.1...0.13.1#files_bucket) 0.13.1 (2021-05-22)
513
* [(link)](https://github.com/haskell-nix/hnix/pull/936/files) `Nix.Parser`: `annotateLocation`: Fix source location preservation.
614
* [(link)](https://github.com/haskell-nix/hnix/pull/934/files) Require Cabal dependency `relude` `>= 1.0`: since imports & Cabal file got cleaned-up & that clean-up depends on `relude` reimports introduced in aforementioned version.

main/Main.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,10 @@ main =
188188
((k, ) <$> forceEntry path nv)
189189
descend
190190
)
191-
(\ v -> pure (k, pure (Free v)))
191+
(\ v -> pure (k, pure $ Free v))
192192
nv
193193
)
194-
(sortWith fst (M.toList s))
194+
(sortWith fst $ M.toList s)
195195
traverse_
196196
(\ (k, mv) ->
197197
do
@@ -256,7 +256,7 @@ main =
256256
Nix.withNixContext
257257
mp
258258
(Nix.reducingEvalExpr
259-
(Eval.eval . annotated . getCompose)
259+
Eval.evalContent
260260
mp
261261
x
262262
)
@@ -272,7 +272,7 @@ main =
272272
liftIO $
273273
do
274274
putStrLn $ "Wrote winnowed expression tree to " <> path
275-
writeFile path $ show $ prettyNix (stripAnnotation expr')
275+
writeFile path $ show $ prettyNix $ stripAnnotation expr'
276276
either
277277
throwM
278278
pure

src/Nix.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ nixEvalExprLoc mpath =
8181
nixEval
8282
mpath
8383
(Eval.addStackFrames . Eval.addSourcePositions)
84-
(Eval.eval . annotated . getCompose)
84+
Eval.evalContent
8585

8686
-- | Evaluate a nix expression with tracing in the default context. Note that
8787
-- this function doesn't do any tracing itself, but 'evalExprLoc' will be

src/Nix/Eval.hs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,4 +556,11 @@ framedEvalExprLoc
556556
=> NExprLoc
557557
-> m v
558558
framedEvalExprLoc =
559-
adi (eval . annotated . getCompose) $ addStackFrames @v . addSourcePositions
559+
adi evalContent $ addStackFrames @v . addSourcePositions
560+
561+
-- | Takes annotated expression. Strip from annotation. Evaluate.
562+
evalContent
563+
:: MonadNixEval v m
564+
=> Compose (Ann ann) NExprF (m v)
565+
-> m v
566+
evalContent = eval . annotated . getCompose

src/Nix/Exec.hs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -526,18 +526,16 @@ evalExprLoc expr =
526526
let
527527
pTracedAdi =
528528
bool
529-
(adi phi addMetaInfo)
529+
(adi Eval.evalContent addMetaInfo)
530530
(join . (`runReaderT` (0 :: Int)) .
531531
adi
532-
(addTracing phi)
532+
(addTracing Eval.evalContent)
533533
(raise addMetaInfo)
534534
)
535535
(tracing opts)
536536
pTracedAdi expr
537537

538538
where
539-
phi = Eval.eval . annotated . getCompose
540-
541539
addMetaInfo :: (Fix NExprLocF -> m a) -> Fix NExprLocF -> m a
542540
addMetaInfo = addStackFrames @(NValue t f m) . addSourcePositions
543541

src/Nix/Lint.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ lint opts expr =
485485
pushScopes
486486
basis
487487
(adi
488-
(Eval.eval . annotated . getCompose)
488+
Eval.evalContent
489489
Eval.addSourcePositions
490490
expr
491491
)

0 commit comments

Comments
 (0)