Passing --debug to hnix when not evaluating dump the parse tree

This commit is contained in:
John Wiegley 2018-03-28 15:48:32 -07:00
parent b97378c581
commit 2c188045cd

View file

@ -52,14 +52,16 @@ main = do
case eres of
Failure err -> hPutStrLn stderr $ "Parse failed: " ++ show err
Success expr ->
if evaluate opts
then if debug opts
then do
expr' <- tracingExprEval expr
print =<< evalStateT (runCyclic expr') baseEnv
else print =<< evalTopLevelExprIO expr
else displayIO stdout $ renderPretty 0.4 80 (prettyNix expr)
Success expr
| evaluate opts, debug opts -> do
expr' <- tracingExprEval expr
print =<< evalStateT (runCyclic expr') baseEnv
| evaluate opts ->
print =<< evalTopLevelExprIO expr
| debug opts ->
print expr
| otherwise ->
displayIO stdout $ renderPretty 0.4 80 (prettyNix expr)
where
optsDef :: ParserInfo Options
optsDef = info (helper <*> mainOptions)