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

27 lines
1021 B
Haskell
Raw Normal View History

module Commands.Dev.Scope where
2022-09-14 17:16:15 +03:00
import Commands.Base
import Commands.Dev.Scope.Options
import Juvix.Compiler.Concrete.Language
import Juvix.Compiler.Concrete.Pretty qualified as Scoper
import Juvix.Compiler.Concrete.Print qualified as Print
2022-09-14 17:16:15 +03:00
import Juvix.Compiler.Concrete.Translation.FromParsed.Analysis.Scoping qualified as Scoper
import Juvix.Prelude.Pretty
2022-09-14 17:16:15 +03:00
runCommand :: (Members '[Embed IO, App] r) => ScopeOptions -> Sem r ()
2022-09-14 17:16:15 +03:00
runCommand opts = do
globalOpts <- askGlobalOptions
res :: Scoper.ScoperResult <- runPipeline (opts ^. scopeInputFile) upToScoping
let modules :: NonEmpty (Module 'Scoped 'ModuleTop) = res ^. Scoper.resultModules
forM_ modules $ \s ->
if
| opts ^. scopeWithComments ->
renderStdOut (Print.ppOut (globalOpts, opts) (res ^. Scoper.comments) s)
| otherwise ->
renderStdOut (Scoper.ppOut (globalOpts, opts) s)
when (opts ^. scopeListComments) $ do
newline
newline
say "Comments:"
say (prettyText (res ^. Scoper.comments))