diff options
author | Marvin Borner | 2022-08-17 18:09:11 +0200 |
---|---|---|
committer | Marvin Borner | 2022-08-17 18:09:11 +0200 |
commit | 266286d108b8304efc67d64f47c1ee9d8d4b17c9 (patch) | |
tree | c1444e9b7a3c4c5ad9a6fb6bfb50903bb8a641ed /src/Eval.hs | |
parent | fee84dce1ed2ac8448b93b7bfaff934bd3c72041 (diff) |
Added input instruction
Diffstat (limited to 'src/Eval.hs')
-rw-r--r-- | src/Eval.hs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/Eval.hs b/src/Eval.hs index 4051643..c80212d 100644 --- a/src/Eval.hs +++ b/src/Eval.hs @@ -122,6 +122,13 @@ evalInstruction (ContextualInstruction instr inp) s@(EnvState env) rec conf = ca then (putStrLn $ name <> " = " <> show e) >> return (EnvState env') else rec (EnvState env') conf + Input path -> do + lib <- getDataFileName path -- TODO: Use actual lib directory + exists <- doesFileExist lib + actual <- pure $ if exists then lib else path + if actual `elem` evalPaths conf then print (ContextualError (ImportError path) (Context inp $ nicePath conf)) >> pure s else do + EnvState env' <- loadFile actual (conf { nicePath = path }) -- TODO: Fix wrong `within` in import error + rec (EnvState $ env' <> env) (conf { isRepl = False, evalPaths = evalPaths conf }) -- import => isRepl = False -- TODO: Don't import subimports into main env Import path namespace -> do lib <- getDataFileName path -- TODO: Use actual lib directory |