1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-15 18:13:56 +03:00
juvix/app/Commands/Dev/Core/Eval.hs

20 lines
709 B
Haskell
Raw Normal View History

2022-09-14 17:16:15 +03:00
module Commands.Dev.Core.Eval where
import Commands.Base
import Commands.Dev.Core.Eval.Options
import Evaluator
2022-09-14 17:16:15 +03:00
import Juvix.Compiler.Core.Data.InfoTable qualified as Core
import Juvix.Compiler.Core.Translation.FromSource qualified as Core
2022-10-21 20:13:06 +03:00
runCommand :: forall r. (Members '[Embed IO, App] r) => CoreEvalOptions -> Sem r ()
2022-09-14 17:16:15 +03:00
runCommand opts = do
2022-12-20 15:05:40 +03:00
f :: Path Abs File <- someBaseToAbs' b
s <- embed (readFile (toFilePath f))
case Core.runParser (toFilePath f) Core.emptyInfoTable s of
2022-09-14 17:16:15 +03:00
Left err -> exitJuvixError (JuvixError err)
2022-10-21 20:13:06 +03:00
Right (tab, Just node) -> do evalAndPrint opts tab node
2022-09-14 17:16:15 +03:00
Right (_, Nothing) -> return ()
where
2022-12-20 15:05:40 +03:00
b :: SomeBase File
b = opts ^. coreEvalInputFile . pathPath