1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-22 06:11:36 +03:00
juvix/app/Commands/Dev/Core/Read.hs

18 lines
685 B
Haskell
Raw Normal View History

2022-09-14 17:16:15 +03:00
module Commands.Dev.Core.Read where
import Commands.Base
import Commands.Dev.Core.Read.Options
import Juvix.Compiler.Core.Pretty qualified as Core
import Juvix.Compiler.Core.Transformation qualified as Core
import Juvix.Compiler.Core.Translation.FromSource qualified as Core
runCommand :: forall r. Members '[Embed IO, App] r => CoreReadOptions -> Sem r ()
runCommand opts = do
s' <- embed (readFile f)
tab <- getRight (fst <$> mapLeft JuvixError (Core.runParser "" f Core.emptyInfoTable s'))
let tab' = Core.applyTransformations (opts ^. coreReadTransformations) tab
renderStdOut (Core.ppOut opts tab')
where
f :: FilePath
f = opts ^. coreReadInputFile . pathPath