From 0b94716c39aa40bace10b1414a7163c3ed8e603c Mon Sep 17 00:00:00 2001 From: Jan Mas Rovira Date: Wed, 4 Dec 2024 14:17:15 +0100 Subject: [PATCH 1/2] rename --- app/Commands/Dev/Nockma/Format.hs | 2 +- app/Commands/Dev/Nockma/Ide/Check.hs | 2 +- src/Juvix/Compiler/Concrete/Data/Highlight/Builder.hs | 4 ++-- src/Juvix/Compiler/Concrete/Data/InfoTableBuilder.hs | 2 +- .../Concrete/Translation/FromParsed/Analysis/Scoping.hs | 4 ++-- src/Juvix/Compiler/Concrete/Translation/FromSource.hs | 4 ++-- .../Concrete/Translation/ImportScanner/Megaparsec.hs | 2 +- src/Juvix/Compiler/Internal/Translation/Repl.hs | 2 +- src/Juvix/Compiler/Nockma/Highlight/Input.hs | 4 ++-- src/Juvix/Compiler/Nockma/Translation/FromSource/Base.hs | 4 ++-- src/Juvix/Compiler/Pipeline/Package/Loader/EvalEff/IO.hs | 2 +- src/Juvix/Compiler/Pipeline/Repl.hs | 6 +++--- src/Juvix/Compiler/Pipeline/Run.hs | 2 +- src/Juvix/Formatter.hs | 4 ++-- 14 files changed, 22 insertions(+), 22 deletions(-) diff --git a/app/Commands/Dev/Nockma/Format.hs b/app/Commands/Dev/Nockma/Format.hs index 9878a814f7..9cc3355a1e 100644 --- a/app/Commands/Dev/Nockma/Format.hs +++ b/app/Commands/Dev/Nockma/Format.hs @@ -10,7 +10,7 @@ runCommand opts = do afile <- fromAppPathFile file parsedTerm <- runAppError @JuvixError - . Nockma.ignoreHighlightBuilder + . Nockma.evalHighlightBuilder $ Nockma.parseTermFile afile putStrLn (ppPrint parsedTerm) where diff --git a/app/Commands/Dev/Nockma/Ide/Check.hs b/app/Commands/Dev/Nockma/Ide/Check.hs index 85f0cb771a..b6d41f716b 100644 --- a/app/Commands/Dev/Nockma/Ide/Check.hs +++ b/app/Commands/Dev/Nockma/Ide/Check.hs @@ -10,6 +10,6 @@ runCommand opts = do afile <- fromAppPathFile (opts ^. nockmaCheckFile) void . runAppError @JuvixError - . ignoreHighlightBuilder + . evalHighlightBuilder $ Nockma.parseTermFile afile renderStdOutLn ("Ok" :: Text) diff --git a/src/Juvix/Compiler/Concrete/Data/Highlight/Builder.hs b/src/Juvix/Compiler/Concrete/Data/Highlight/Builder.hs index 97fb216d4f..e857f7e764 100644 --- a/src/Juvix/Compiler/Concrete/Data/Highlight/Builder.hs +++ b/src/Juvix/Compiler/Concrete/Data/Highlight/Builder.hs @@ -34,8 +34,8 @@ runHighlightBuilder = reinterpret (runStateShared emptyHighlightInput) $ \case HighlightMergeDocTable tbl -> modifyShared (over highlightDocTable (HashMap.union tbl)) GetDocTable uid -> filterByTopModule uid <$> getsShared (^. highlightDocTable) -ignoreHighlightBuilder :: Sem (HighlightBuilder ': r) a -> Sem r a -ignoreHighlightBuilder = fmap snd . runHighlightBuilder +evalHighlightBuilder :: Sem (HighlightBuilder ': r) a -> Sem r a +evalHighlightBuilder = fmap snd . runHighlightBuilder runJuvixError :: (Members '[HighlightBuilder] r) => Sem (Error JuvixError ': r) a -> Sem r (Either JuvixError a) runJuvixError m = do diff --git a/src/Juvix/Compiler/Concrete/Data/InfoTableBuilder.hs b/src/Juvix/Compiler/Concrete/Data/InfoTableBuilder.hs index 664fa714c7..fbb4d44358 100644 --- a/src/Juvix/Compiler/Concrete/Data/InfoTableBuilder.hs +++ b/src/Juvix/Compiler/Concrete/Data/InfoTableBuilder.hs @@ -138,7 +138,7 @@ registerBuiltinHelper b n = do } runInfoTableBuilderRepl :: (Members '[Error ScoperError] r) => InfoTable -> Sem (InfoTableBuilder ': r) a -> Sem r (InfoTable, a) -runInfoTableBuilderRepl tab = ignoreHighlightBuilder . runInfoTableBuilder tab . raiseUnder +runInfoTableBuilderRepl tab = evalHighlightBuilder . runInfoTableBuilder tab . raiseUnder ignoreInfoTableBuilder :: (Members '[Error ScoperError, HighlightBuilder] r) => Sem (InfoTableBuilder ': r) a -> Sem r a ignoreInfoTableBuilder = fmap snd . runInfoTableBuilder mempty diff --git a/src/Juvix/Compiler/Concrete/Translation/FromParsed/Analysis/Scoping.hs b/src/Juvix/Compiler/Concrete/Translation/FromParsed/Analysis/Scoping.hs index a899eb8a37..e1d2747508 100644 --- a/src/Juvix/Compiler/Concrete/Translation/FromParsed/Analysis/Scoping.hs +++ b/src/Juvix/Compiler/Concrete/Translation/FromParsed/Analysis/Scoping.hs @@ -105,7 +105,7 @@ scopeCheckRepl :: Sem r b scopeCheckRepl check importTab tab a = mapError (JuvixError @ScoperError) - . ignoreHighlightBuilder + . evalHighlightBuilder . evalInfoTableBuilder tab . runReader iniScopeParameters . runReader tab' @@ -3215,7 +3215,7 @@ checkJudoc :: Judoc 'Parsed -> Sem r (Judoc 'Scoped) checkJudoc (Judoc groups) = - ignoreHighlightBuilder + evalHighlightBuilder . ignoreInfoTableBuilder $ Judoc <$> mapM checkJudocGroup groups diff --git a/src/Juvix/Compiler/Concrete/Translation/FromSource.hs b/src/Juvix/Compiler/Concrete/Translation/FromSource.hs index 47d485b522..df062611b7 100644 --- a/src/Juvix/Compiler/Concrete/Translation/FromSource.hs +++ b/src/Juvix/Compiler/Concrete/Translation/FromSource.hs @@ -17,7 +17,7 @@ import Data.Text qualified as Text import Juvix.Compiler.Backend.Markdown.Data.Types (Mk (..)) import Juvix.Compiler.Backend.Markdown.Data.Types qualified as MK import Juvix.Compiler.Backend.Markdown.Error -import Juvix.Compiler.Concrete (HighlightBuilder, ignoreHighlightBuilder) +import Juvix.Compiler.Concrete (HighlightBuilder, evalHighlightBuilder) import Juvix.Compiler.Concrete.Extra (takeWhile1P) import Juvix.Compiler.Concrete.Extra qualified as P import Juvix.Compiler.Concrete.Gen qualified as Gen @@ -294,7 +294,7 @@ runExpressionParser :: Sem r (Either ParserError (ExpressionAtoms 'Parsed)) runExpressionParser fpath input_ = do m <- - ignoreHighlightBuilder + evalHighlightBuilder . evalParserResultBuilder mempty . evalState (Nothing @ParsedPragmas) . evalState (Nothing @(Judoc 'Parsed)) diff --git a/src/Juvix/Compiler/Concrete/Translation/ImportScanner/Megaparsec.hs b/src/Juvix/Compiler/Concrete/Translation/ImportScanner/Megaparsec.hs index 1cf14012a0..e44bf8fd83 100644 --- a/src/Juvix/Compiler/Concrete/Translation/ImportScanner/Megaparsec.hs +++ b/src/Juvix/Compiler/Concrete/Translation/ImportScanner/Megaparsec.hs @@ -21,7 +21,7 @@ scanBSImports :: Sem r ScanResult scanBSImports fp inputBS = do st <- - ignoreHighlightBuilder + evalHighlightBuilder . execParserResultBuilder mempty . ignoreTopModuleNameChecker $ runModuleParser fp (decodeUtf8 inputBS) diff --git a/src/Juvix/Compiler/Internal/Translation/Repl.hs b/src/Juvix/Compiler/Internal/Translation/Repl.hs index d4ab9aefa1..1562eb58bd 100644 --- a/src/Juvix/Compiler/Internal/Translation/Repl.hs +++ b/src/Juvix/Compiler/Internal/Translation/Repl.hs @@ -24,7 +24,7 @@ typeCheckExpressionType exp = do stable <- gets (^. artifactScopeTable) runResultBuilderArtifacts . runNameIdGenArtifacts - . ignoreHighlightBuilder + . evalHighlightBuilder . runReader table . runReader (stable ^. infoBuiltins) . runReader stable diff --git a/src/Juvix/Compiler/Nockma/Highlight/Input.hs b/src/Juvix/Compiler/Nockma/Highlight/Input.hs index 2c53d70867..fca8d4da6e 100644 --- a/src/Juvix/Compiler/Nockma/Highlight/Input.hs +++ b/src/Juvix/Compiler/Nockma/Highlight/Input.hs @@ -39,8 +39,8 @@ data HighlightBuilder :: Effect where makeSem ''HighlightBuilder -ignoreHighlightBuilder :: Sem (HighlightBuilder ': r) a -> Sem r a -ignoreHighlightBuilder = interpret $ \case +evalHighlightBuilder :: Sem (HighlightBuilder ': r) a -> Sem r a +evalHighlightBuilder = interpret $ \case HighlightItem {} -> return () HighlightNockOp {} -> return () HighlightPath {} -> return () diff --git a/src/Juvix/Compiler/Nockma/Translation/FromSource/Base.hs b/src/Juvix/Compiler/Nockma/Translation/FromSource/Base.hs index 917919fa97..ca715fc001 100644 --- a/src/Juvix/Compiler/Nockma/Translation/FromSource/Base.hs +++ b/src/Juvix/Compiler/Nockma/Translation/FromSource/Base.hs @@ -40,7 +40,7 @@ cueJammedFileOrPretty :: Prelude.Path Abs File -> Sem r (Term Natural) cueJammedFileOrPretty f - | f `hasExtensions` nockmaDebugFileExts = ignoreHighlightBuilder (parseTermFile f) + | f `hasExtensions` nockmaDebugFileExts = evalHighlightBuilder (parseTermFile f) | otherwise = cueJammedFile f -- | If the file ends in .debug.nockma it parses an annotated unjammed program. Otherwise @@ -114,7 +114,7 @@ runParserForSem p f txt = do Right t -> return t runParserFor :: Parser a -> Prelude.Path Abs File -> Text -> Either MegaparsecError a -runParserFor p f = run . ignoreHighlightBuilder . runError . runParserForSem p f +runParserFor p f = run . evalHighlightBuilder . runError . runParserForSem p f runParser :: Prelude.Path Abs File -> Text -> Either MegaparsecError (Term Natural) runParser = runParserFor term diff --git a/src/Juvix/Compiler/Pipeline/Package/Loader/EvalEff/IO.hs b/src/Juvix/Compiler/Pipeline/Package/Loader/EvalEff/IO.hs index 434c10c4a6..ca57b854ea 100644 --- a/src/Juvix/Compiler/Pipeline/Package/Loader/EvalEff/IO.hs +++ b/src/Juvix/Compiler/Pipeline/Package/Loader/EvalEff/IO.hs @@ -126,7 +126,7 @@ loadPackage' packagePath = do . runConcurrent . ignoreLogger . evalInternetOffline - . ignoreHighlightBuilder + . evalHighlightBuilder . runProcessIO . runFilesIO . evalTopNameIdGen defaultModuleId diff --git a/src/Juvix/Compiler/Pipeline/Repl.hs b/src/Juvix/Compiler/Pipeline/Repl.hs index 493930e2be..db3a86be8f 100644 --- a/src/Juvix/Compiler/Pipeline/Repl.hs +++ b/src/Juvix/Compiler/Pipeline/Repl.hs @@ -1,6 +1,6 @@ module Juvix.Compiler.Pipeline.Repl where -import Juvix.Compiler.Concrete (ignoreHighlightBuilder) +import Juvix.Compiler.Concrete (evalHighlightBuilder) import Juvix.Compiler.Concrete.Language import Juvix.Compiler.Concrete.Translation.FromParsed qualified as Scoper import Juvix.Compiler.Concrete.Translation.FromSource qualified as Parser @@ -89,7 +89,7 @@ parseReplInput :: Text -> Sem r Parser.ReplInput parseReplInput fp txt = - ignoreHighlightBuilder + evalHighlightBuilder . runNameIdGenArtifacts . runStateLikeArtifacts runParserResultBuilder artifactParsing $ Parser.replInputFromTextSource fp txt @@ -165,7 +165,7 @@ compileReplInputIO fp txt = do . runLoggerIO replLoggerOptions . runReader defaultNumThreads . evalInternet hasInternet - . ignoreHighlightBuilder + . evalHighlightBuilder . runTaggedLockPermissive . runFilesIO . mapError (JuvixError @GitProcessError) diff --git a/src/Juvix/Compiler/Pipeline/Run.hs b/src/Juvix/Compiler/Pipeline/Run.hs index aad458a24e..979a56c610 100644 --- a/src/Juvix/Compiler/Pipeline/Run.hs +++ b/src/Juvix/Compiler/Pipeline/Run.hs @@ -215,7 +215,7 @@ runReplPipelineIOEither' lockMode entry = do . runConcurrent . runReader defaultNumThreads . evalInternet hasInternet - . ignoreHighlightBuilder + . evalHighlightBuilder . runError . runState initialArtifacts . runNameIdGenArtifacts diff --git a/src/Juvix/Formatter.hs b/src/Juvix/Formatter.hs index 19e6fcffab..a0185a4cf4 100644 --- a/src/Juvix/Formatter.hs +++ b/src/Juvix/Formatter.hs @@ -2,7 +2,7 @@ module Juvix.Formatter where -import Juvix.Compiler.Concrete.Data.Highlight.Builder (ignoreHighlightBuilder) +import Juvix.Compiler.Concrete.Data.Highlight.Builder (evalHighlightBuilder) import Juvix.Compiler.Concrete.Language import Juvix.Compiler.Concrete.Print (ppOutDefault) import Juvix.Compiler.Concrete.Translation.FromParsed.Analysis.Scoping (ScoperResult, getModuleId, scopeCheck) @@ -118,7 +118,7 @@ formatModuleInfo :: Sem r SourceCode formatModuleInfo node moduleInfo = withResolverRoot (node ^. importNodePackageRoot) - . ignoreHighlightBuilder + . evalHighlightBuilder $ do pkg :: PackageId <- ask parseRes :: ParserResult <- From 8fa54ab602adc790aba237acf96a6523c807c993 Mon Sep 17 00:00:00 2001 From: Jan Mas Rovira Date: Wed, 4 Dec 2024 14:20:02 +0100 Subject: [PATCH 2/2] properly register comments as parsed items --- .../Translation/FromSource/ParserResultBuilder.hs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Juvix/Compiler/Concrete/Translation/FromSource/ParserResultBuilder.hs b/src/Juvix/Compiler/Concrete/Translation/FromSource/ParserResultBuilder.hs index f4b4c4234f..96cac9db12 100644 --- a/src/Juvix/Compiler/Concrete/Translation/FromSource/ParserResultBuilder.hs +++ b/src/Juvix/Compiler/Concrete/Translation/FromSource/ParserResultBuilder.hs @@ -95,12 +95,14 @@ runParserResultBuilder s = registerItem' i RegisterSpaceSpan g -> do modify' (over parserStateComments (g :)) - forM_ (g ^.. spaceSpan . each . _SpaceComment) $ \c -> - registerItem' - ParsedItem - { _parsedLoc = getLoc c, - _parsedTag = ParsedTagComment - } + forM_ (g ^.. spaceSpan . each . _SpaceComment) $ \c -> do + let i = + ParsedItem + { _parsedLoc = getLoc c, + _parsedTag = ParsedTagComment + } + highlightParsedItem i + registerItem' i ignoreParserResultBuilder :: Sem (ParserResultBuilder ': r) a -> Sem r a ignoreParserResultBuilder = interpret $ \case