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

26 lines
972 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.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 (Print.ppOutNoComments (globalOpts, opts) s)
when (opts ^. scopeListComments) $ do
newline
newline
say "Comments:"
say (prettyText (res ^. Scoper.comments))