Add --scopes option to print out scoping information
This commit is contained in:
parent
36864cdbb4
commit
705d7c474d
|
@ -8,6 +8,7 @@ data Options = Options
|
|||
, tracing :: Bool
|
||||
, thunks :: Bool
|
||||
, values :: Bool
|
||||
, scopes :: Bool
|
||||
, reduce :: Maybe FilePath
|
||||
, reduceSets :: Bool
|
||||
, reduceLists :: Bool
|
||||
|
@ -41,6 +42,7 @@ defaultOptions current = Options
|
|||
, tracing = False
|
||||
, thunks = False
|
||||
, values = False
|
||||
, scopes = False
|
||||
, reduce = Nothing
|
||||
, reduceSets = False
|
||||
, reduceLists = False
|
||||
|
|
|
@ -45,6 +45,9 @@ nixOptions current = Options
|
|||
<*> switch
|
||||
( long "values"
|
||||
<> help "Enable reporting of value provenance in error messages")
|
||||
<*> switch
|
||||
( long "scopes"
|
||||
<> help "Enable reporting of scopes in evaluation traces")
|
||||
<*> optional (strOption
|
||||
( long "reduce"
|
||||
<> help "When done evaluating, output the evaluated part of the expression to FILE"))
|
||||
|
|
|
@ -92,8 +92,10 @@ renderEvalFrame :: (MonadReader e m, Has e Options, MonadFile m)
|
|||
renderEvalFrame level f = do
|
||||
opts :: Options <- asks (view hasLens)
|
||||
case f of
|
||||
EvaluatingExpr _scope e@(Fix (Compose (Ann ann _))) ->
|
||||
fmap (:[]) $ renderLocation ann
|
||||
EvaluatingExpr scope e@(Fix (Compose (Ann ann _))) -> do
|
||||
let scopeInfo | scopes opts = [string (show scope)]
|
||||
| otherwise = []
|
||||
fmap (\x -> scopeInfo ++ [x]) $ renderLocation ann
|
||||
=<< renderExpr level "While evaluating" "Expression" e
|
||||
|
||||
ForcingExpr _scope e@(Fix (Compose (Ann ann _)))
|
||||
|
|
Loading…
Reference in a new issue