1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-15 10:03:22 +03:00
juvix/app/Commands/Dev/Asm/Run.hs
Paul Cadman 32449e1212
Use system locale independent readFile and writeFile APIs from with-utf8 (#2473)
The problem with readFile and writeFile from text
[Data.Text.IO](https://hackage.haskell.org/package/text-2.0.2/docs/Data-Text-IO.html)
is that they use the system locale to determine the text encoding
format.

Our assumption is that all Juvix source files are UTF-8 encoded.

I cannot reproduce the issue with using the old APIs on my machine, it
can be reproduced on Arch linux. I'm not sure how to write a specific
test for this.

* Closes https://github.com/anoma/juvix/issues/2472
2023-10-26 09:13:33 +01:00

18 lines
590 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 '[Embed IO, App] r) => AsmRunOptions -> Sem r ()
runCommand opts = do
afile :: Path Abs File <- fromAppPathFile file
s <- readFile (toFilePath afile)
case Asm.runParser (toFilePath afile) s of
Left err -> exitJuvixError (JuvixError err)
Right tab -> runAsm (not (opts ^. asmRunNoValidate)) tab
where
file :: AppPath File
file = opts ^. asmRunInputFile