Skip to content

Commit 4796681

Browse files
Merge #884 Parser: Result is synonim of Either; Thunk.Basic: nonblocking queryM, internal changes to force*
* [(link)](https://github.com/haskell-nix/hnix/pull/884/files) `Nix.Parser`: `Parser`: Data type was equivalent to `Either`, so became a type synonim for `Either`. * [(link)](https://github.com/haskell-nix/hnix/pull/884/files) `Nix.Thunk.Basic`: `instance MonadThunk (NThunkF m v) m v`: `queryM`: implementation no longer blocks the thunk resource it only reads from.
2 parents 36802ae + c30b164 commit 4796681

39 files changed

+1227
-963
lines changed

.github/workflows/Cabal-Linux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
runs-on: ubuntu-latest
1919
strategy:
2020
matrix:
21-
ghc: [ "8.10", "8.4" ]
21+
ghc: [ "8.10", "8.6" ]
2222
steps:
2323

2424
- name: "Git checkout"

.github/workflows/On-Release-Cabal-Linux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
strategy:
1717
matrix:
1818
# Since CI by default tests boundary GHCs, test middle versions of GHCs
19-
ghc: [ "8.8", "8.6"]
19+
ghc: [ "8.8" ]
2020
steps:
2121
- name: "Git checkout"
2222
uses: actions/checkout@v2

ChangeLog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@
142142
* [(link)](https://github.com/haskell-nix/hnix/pull/878/files) `Nix.Pretty`: `mkNixDoc`: got unflipped.
143143

144144
* [(link)](https://github.com/haskell-nix/hnix/pull/886/commits/381b0e5df9cc620a25533ff1c84045a4ea37a833) `Nix.Value`: Data constructor for `NValue' t f m a` changed (`NValue -> NValue'`).
145+
146+
* [(link)](https://github.com/haskell-nix/hnix/pull/884/files) `Nix.Parser`: `Parser`: Data type was equivalent to `Either`, so became a type synonim for `Either`.
147+
148+
* [(link)](https://github.com/haskell-nix/hnix/pull/884/files) `Nix.Thunk.Basic`: `instance MonadThunk (NThunkF m v) m v`: `queryM`: implementation no longer blocks the thunk resource it only reads from.
149+
145150

146151
* Additional:
147152
* [(link)](https://github.com/haskell-nix/hnix/commit/7e6cd97bf3288cb584241611fdb25bf85d7e0ba7) `cabal.project`: freed from the `cryptohash-sha512` override, Hackage trustees made a revision.

hnix.cabal

Lines changed: 392 additions & 384 deletions
Large diffs are not rendered by default.

main/Main.hs

Lines changed: 45 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -85,48 +85,54 @@ main = do
8585
)
8686
(readFrom opts)
8787

88-
processFile opts path = do
89-
eres <- parseNixFileLoc path
90-
handleResult opts (pure path) eres
88+
processFile opts path =
89+
do
90+
eres <- parseNixFileLoc path
91+
handleResult opts (pure path) eres
9192

92-
handleResult opts mpath = \case
93-
Failure err ->
94-
bool
95-
errorWithoutStackTrace
96-
(liftIO . hPutStrLn stderr)
97-
(ignoreErrors opts)
98-
$ "Parse failed: " <> show err
93+
handleResult opts mpath =
94+
either
95+
(\ err ->
96+
bool
97+
errorWithoutStackTrace
98+
(liftIO . hPutStrLn stderr)
99+
(ignoreErrors opts)
100+
$ "Parse failed: " <> show err
101+
)
99102

100-
Success expr -> do
101-
when (check opts) $ do
102-
expr' <- liftIO (reduceExpr mpath expr)
103-
either
104-
(\ err -> errorWithoutStackTrace $ "Type error: " <> PS.ppShow err)
105-
(\ ty -> liftIO $ putStrLn $ "Type of expression: " <> PS.ppShow
106-
(fromJust $ Map.lookup "it" $ Env.types ty)
107-
)
108-
(HM.inferTop Env.empty [("it", stripAnnotation expr')])
103+
(\ expr ->
104+
do
105+
when (check opts) $
106+
do
107+
expr' <- liftIO (reduceExpr mpath expr)
108+
either
109+
(\ err -> errorWithoutStackTrace $ "Type error: " <> PS.ppShow err)
110+
(\ ty -> liftIO $ putStrLn $ "Type of expression: " <> PS.ppShow
111+
(fromJust $ Map.lookup "it" $ Env.types ty)
112+
)
113+
(HM.inferTop Env.empty [("it", stripAnnotation expr')])
109114

110-
-- liftIO $ putStrLn $ runST $
111-
-- runLintM opts . renderSymbolic =<< lint opts expr
115+
-- liftIO $ putStrLn $ runST $
116+
-- runLintM opts . renderSymbolic =<< lint opts expr
112117

113-
catch (process opts mpath expr) $ \case
114-
NixException frames ->
115-
errorWithoutStackTrace
116-
. show
117-
=<< renderFrames @(StdValue (StandardT (StdIdT IO)))
118-
@(StdThunk (StandardT (StdIdT IO)))
119-
frames
118+
catch (process opts mpath expr) $
119+
\case
120+
NixException frames ->
121+
errorWithoutStackTrace . show
122+
=<< renderFrames @(StdValue (StandardT (StdIdT IO)))
123+
@(StdThunk (StandardT (StdIdT IO)))
124+
frames
120125

121-
when (repl opts) $
122-
withNixContext mempty $
123-
bool
124-
Repl.main
125-
(do
126-
val <- Nix.nixEvalExprLoc mpath expr
127-
Repl.main' $ pure val
128-
)
129-
(evaluate opts)
126+
when (repl opts) $
127+
withNixContext mempty $
128+
bool
129+
Repl.main
130+
(do
131+
val <- Nix.nixEvalExprLoc mpath expr
132+
Repl.main' $ pure val
133+
)
134+
(evaluate opts)
135+
)
130136

131137
process opts mpath expr
132138
| evaluate opts =
@@ -137,8 +143,8 @@ main = do
137143
&& null (argstr opts)
138144
) -> evaluateExpression mpath Nix.nixEvalExprLoc printer expr
139145
| otherwise -> processResult printer =<< Nix.nixEvalExprLoc mpath expr
140-
| xml opts = error "Rendering expression trees to XML is not yet implemented"
141-
| json opts = error "Rendering expression trees to JSON is not implemented"
146+
| xml opts = fail "Rendering expression trees to XML is not yet implemented"
147+
| json opts = fail "Rendering expression trees to JSON is not implemented"
142148
| verbose opts >= DebugInfo = liftIO $ putStr $ PS.ppShow $ stripAnnotation expr
143149
| cache opts
144150
, Just path <- mpath = liftIO $ writeCache (addExtension (dropExtension path) "nixc") expr

0 commit comments

Comments
 (0)