Some improvements to error traces
This commit is contained in:
parent
d08ca26da0
commit
b89b795abe
|
@ -185,7 +185,7 @@ eval (NApp fun arg) = fun >>= \case
|
|||
++ show (newScope args)
|
||||
clearScopes (pushScope args (forceThunk =<< f))
|
||||
NVBuiltin _ f -> f =<< buildThunk arg
|
||||
_ -> throwError "Attempt to call non-function"
|
||||
x -> throwError $ "Attempt to call non-function: " ++ show (() <$ x)
|
||||
|
||||
eval (NAbs params body) = do
|
||||
-- It is the environment at the definition site, not the call site, that
|
||||
|
|
|
@ -151,16 +151,17 @@ instance MonadNixEnv (Cyclic IO) where
|
|||
return $ dir' </> path
|
||||
x -> error $ "How can the current directory be: " ++ show x
|
||||
traceM $ "Importing file " ++ path'
|
||||
eres <- Cyclic $ parseNixFile path'
|
||||
case eres of
|
||||
Failure err -> error $ "Parse failed: " ++ show err
|
||||
Success expr -> do
|
||||
ref <- buildThunk $ return $
|
||||
NVLiteralPath $ takeDirectory path'
|
||||
-- Use this cookie so that when we evaluate the next
|
||||
-- import, we'll remember which directory its containing
|
||||
-- file was in.
|
||||
pushScope (Map.singleton "__cwd" ref) (evalExpr expr)
|
||||
withStringContext ("While importing file " ++ show path') $ do
|
||||
eres <- Cyclic $ parseNixFile path'
|
||||
case eres of
|
||||
Failure err -> error $ "Parse failed: " ++ show err
|
||||
Success expr -> do
|
||||
ref <- buildThunk $ return $
|
||||
NVLiteralPath $ takeDirectory path'
|
||||
-- Use this cookie so that when we evaluate the next
|
||||
-- import, we'll remember which directory its containing
|
||||
-- file was in.
|
||||
pushScope (Map.singleton "__cwd" ref) (evalExpr expr)
|
||||
p -> error $ "Unexpected argument to import: " ++ show (() <$ p)
|
||||
|
||||
getEnvVar = forceThunk >=> \case
|
||||
|
|
|
@ -1 +1 @@
|
|||
"Hello, world!"
|
||||
"Hello, world!" 10
|
||||
|
|
Loading…
Reference in a new issue