1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-28 18:11:49 +03:00
juvix/app/Commands/Dev/Asm/Run.hs
Jan Mas Rovira a825f41507
Refactor readFile and some parsers to use Path instead of FilePath (#2649)
Now the prelude exports this function:
```
readFile :: (MonadIO m) => Path Abs File -> m Text
readFile = liftIO . Utf8.readFile . toFilePath
```
It is more convenient to use because it uses typed `Path` and works in
any `MonadIO`.
2024-02-19 17:33:58 +01:00

18 lines
563 B
Haskell

module Commands.Dev.Asm.Run where
import AsmInterpreter
import Commands.Base
import Commands.Dev.Asm.Run.Options
import Juvix.Compiler.Asm.Translation.FromSource qualified as Asm
runCommand :: forall r. (Members '[EmbedIO, App] r) => AsmRunOptions -> Sem r ()
runCommand opts = do
afile :: Path Abs File <- fromAppPathFile file
s <- readFile afile
case Asm.runParser afile s of
Left err -> exitJuvixError (JuvixError err)
Right tab -> runAsm (not (opts ^. asmRunNoValidate)) tab
where
file :: AppPath File
file = opts ^. asmRunInputFile