From 066a83c9000528694ce72a9ca19de1377b287b94 Mon Sep 17 00:00:00 2001 From: Jan Mas Rovira Date: Fri, 3 May 2024 13:12:23 +0200 Subject: [PATCH] remove unused Reader ImportScanStrategy from pipeline --- app/Commands/Dev/ImportTree/Print.hs | 25 +++++++++---------- src/Juvix/Compiler/Pipeline.hs | 3 +-- .../Pipeline/Artifacts/PathResolver.hs | 5 ++-- .../Compiler/Pipeline/Loader/PathResolver.hs | 24 +++++++++--------- .../Pipeline/Package/Loader/EvalEff/IO.hs | 2 -- .../Pipeline/Package/Loader/PathResolver.hs | 7 +++--- src/Juvix/Compiler/Pipeline/Repl.hs | 2 -- src/Juvix/Compiler/Pipeline/Run.hs | 3 --- 8 files changed, 30 insertions(+), 41 deletions(-) diff --git a/app/Commands/Dev/ImportTree/Print.hs b/app/Commands/Dev/ImportTree/Print.hs index 8ebae03cfe..e3632dd85f 100644 --- a/app/Commands/Dev/ImportTree/Print.hs +++ b/app/Commands/Dev/ImportTree/Print.hs @@ -9,16 +9,15 @@ import Juvix.Compiler.Pipeline.Setup import Juvix.Parser.Error runCommand :: (Members '[EmbedIO, App, TaggedLock] r) => PrintOptions -> Sem r () -runCommand PrintOptions {..} = - runPipelineSetup - . local (const _printScanStrategy) - $ do - entrySetup defaultDependenciesConfig - tree <- - mapError (JuvixError @ParserError) - . mapError (JuvixError @ScoperError) - $ mkImportTree - renderStdOut (ppOutDefaultNoComments tree) - when _printStats $ do - let stats = mkImportTreeStats tree - renderStdOut (ppOutDefaultNoComments stats) +runCommand PrintOptions {..} = runPipelineSetup $ + do + entrySetup defaultDependenciesConfig + tree <- + runReader _printScanStrategy + . mapError (JuvixError @ParserError) + . mapError (JuvixError @ScoperError) + $ mkImportTree + renderStdOut (ppOutDefaultNoComments tree) + when _printStats $ do + let stats = mkImportTreeStats tree + renderStdOut (ppOutDefaultNoComments stats) diff --git a/src/Juvix/Compiler/Pipeline.hs b/src/Juvix/Compiler/Pipeline.hs index 0688b6220f..3204824b73 100644 --- a/src/Juvix/Compiler/Pipeline.hs +++ b/src/Juvix/Compiler/Pipeline.hs @@ -25,7 +25,6 @@ import Juvix.Compiler.Concrete.Language import Juvix.Compiler.Concrete.Translation.FromParsed qualified as Scoper import Juvix.Compiler.Concrete.Translation.FromSource qualified as Parser import Juvix.Compiler.Concrete.Translation.FromSource.TopModuleNameChecker -import Juvix.Compiler.Concrete.Translation.ImportScanner import Juvix.Compiler.Core qualified as Core import Juvix.Compiler.Core.Transformation import Juvix.Compiler.Core.Translation.Stripped.FromCore qualified as Stripped @@ -53,7 +52,7 @@ import Juvix.Data.Field type PipelineAppEffects = '[TaggedLock, EmbedIO] -type PipelineLocalEff = '[ModuleInfoCache, Reader ImportParents, TopModuleNameChecker, PathResolver, Reader ImportScanStrategy, EvalFileEff, Error PackageLoaderError, Error DependencyError, GitClone, Error GitProcessError, Process, Log, Reader EntryPoint, Files, Error JuvixError, HighlightBuilder, Internet] +type PipelineLocalEff = '[ModuleInfoCache, Reader ImportParents, TopModuleNameChecker, PathResolver, EvalFileEff, Error PackageLoaderError, Error DependencyError, GitClone, Error GitProcessError, Process, Log, Reader EntryPoint, Files, Error JuvixError, HighlightBuilder, Internet] type PipelineEff' r = PipelineLocalEff ++ r diff --git a/src/Juvix/Compiler/Pipeline/Artifacts/PathResolver.hs b/src/Juvix/Compiler/Pipeline/Artifacts/PathResolver.hs index 428e72e401..8d2804f839 100644 --- a/src/Juvix/Compiler/Pipeline/Artifacts/PathResolver.hs +++ b/src/Juvix/Compiler/Pipeline/Artifacts/PathResolver.hs @@ -1,6 +1,5 @@ module Juvix.Compiler.Pipeline.Artifacts.PathResolver where -import Juvix.Compiler.Concrete.Translation.ImportScanner import Juvix.Compiler.Pipeline.Artifacts import Juvix.Compiler.Pipeline.EntryPoint import Juvix.Compiler.Pipeline.Loader.PathResolver @@ -10,8 +9,8 @@ import Juvix.Data.Effect.Git import Juvix.Data.Effect.TaggedLock import Juvix.Prelude -runPathResolverArtifacts :: (Members '[Reader ImportScanStrategy, TaggedLock, Files, Reader EntryPoint, State Artifacts, Error DependencyError, GitClone, Error JuvixError, EvalFileEff] r) => Sem (PathResolver ': r) a -> Sem r a +runPathResolverArtifacts :: (Members '[TaggedLock, Files, Reader EntryPoint, State Artifacts, Error DependencyError, GitClone, Error JuvixError, EvalFileEff] r) => Sem (PathResolver ': r) a -> Sem r a runPathResolverArtifacts = runStateLikeArtifacts runPathResolverPipe' artifactResolver -runPackagePathResolverArtifacts :: (Members '[Reader ImportScanStrategy, TaggedLock, Files, Reader EntryPoint, State Artifacts, Error DependencyError, GitClone, Error JuvixError, EvalFileEff] r) => Path Abs Dir -> Sem (PathResolver ': r) a -> Sem r a +runPackagePathResolverArtifacts :: (Members '[TaggedLock, Files, Reader EntryPoint, State Artifacts, Error DependencyError, GitClone, Error JuvixError, EvalFileEff] r) => Path Abs Dir -> Sem (PathResolver ': r) a -> Sem r a runPackagePathResolverArtifacts root = runStateLikeArtifacts (runPackagePathResolver'' root) artifactResolver diff --git a/src/Juvix/Compiler/Pipeline/Loader/PathResolver.hs b/src/Juvix/Compiler/Pipeline/Loader/PathResolver.hs index 90b93179ba..b5cc8fc923 100644 --- a/src/Juvix/Compiler/Pipeline/Loader/PathResolver.hs +++ b/src/Juvix/Compiler/Pipeline/Loader/PathResolver.hs @@ -60,7 +60,7 @@ findPackageJuvixFiles pkgRoot = map (fromJust . stripProperPrefix pkgRoot) <$> w mkPackageInfo :: forall r. - (Members '[Reader ImportScanStrategy, TaggedLock, Files, Error JuvixError, Reader ResolverEnv, Error DependencyError, GitClone] r) => + (Members '[TaggedLock, Files, Error JuvixError, Reader ResolverEnv, Error DependencyError, GitClone] r) => Maybe EntryPoint -> Path Abs Dir -> Package -> @@ -178,7 +178,7 @@ resolveDependency i = case i ^. packageDepdendencyInfoDependency of registerPackageBase :: forall r. - (Members '[Reader ImportScanStrategy, Error ParserError, TaggedLock, State ResolverState, Files] r) => + (Members '[Error ParserError, TaggedLock, State ResolverState, Files] r) => Sem r () registerPackageBase = do packageBaseAbsDir <- globalPackageBaseRoot @@ -206,7 +206,7 @@ registerPackageBase = do registerDependencies' :: forall r. - (Members '[Reader ImportScanStrategy, TaggedLock, Reader EntryPoint, Files, Error JuvixError, Error DependencyError, GitClone, EvalFileEff] r) => + (Members '[TaggedLock, Reader EntryPoint, Files, Error JuvixError, Error DependencyError, GitClone, EvalFileEff] r) => DependenciesConfig -> Sem (Reader ResolverEnv ': State ResolverState ': r) () registerDependencies' conf = do @@ -243,7 +243,7 @@ registerDependencies' conf = do addRootDependency :: forall r. - (Members '[Reader ImportScanStrategy, TaggedLock, State ResolverState, Reader ResolverEnv, Files, Error JuvixError, Error DependencyError, GitClone, EvalFileEff] r) => + (Members '[TaggedLock, State ResolverState, Reader ResolverEnv, Files, Error JuvixError, Error DependencyError, GitClone, EvalFileEff] r) => DependenciesConfig -> EntryPoint -> Path Abs Dir -> @@ -272,7 +272,7 @@ addRootDependency conf e root = do addDependency :: forall r. - (Members '[Reader ImportScanStrategy, TaggedLock, State ResolverState, Reader ResolverEnv, Files, Error JuvixError, Error DependencyError, GitClone, EvalFileEff] r) => + (Members '[TaggedLock, State ResolverState, Reader ResolverEnv, Files, Error JuvixError, Error DependencyError, GitClone, EvalFileEff] r) => Maybe EntryPoint -> PackageDependencyInfo -> Sem r LockfileDependency @@ -294,7 +294,7 @@ addPackageRelativeFiles pkgInfo = addDependency' :: forall r. - (Members '[Reader ImportScanStrategy, TaggedLock, State ResolverState, Reader ResolverEnv, Files, Error JuvixError, Error DependencyError, GitClone, EvalFileEff] r) => + (Members '[TaggedLock, State ResolverState, Reader ResolverEnv, Files, Error JuvixError, Error DependencyError, GitClone, EvalFileEff] r) => Package -> Maybe EntryPoint -> ResolvedDependency -> @@ -504,7 +504,7 @@ expectedPath' m = do runPathResolver2 :: forall r a v. - (v ~ '[Reader ImportScanStrategy, TaggedLock, Reader EntryPoint, Files, Error JuvixError, Error DependencyError, GitClone, EvalFileEff], Members v r) => + (v ~ '[TaggedLock, Reader EntryPoint, Files, Error JuvixError, Error DependencyError, GitClone, EvalFileEff], Members v r) => ResolverState -> ResolverEnv -> Sem (PathResolver ': r) a -> @@ -545,10 +545,10 @@ runPathResolver2 st topEnv arg = do } localSeqUnlift localEnv $ \unlift -> local (const env') (unlift m) -runPathResolver :: (Members '[Reader ImportScanStrategy, TaggedLock, Reader EntryPoint, Files, Error JuvixError, Error DependencyError, GitClone, EvalFileEff] r) => Path Abs Dir -> Sem (PathResolver ': r) a -> Sem r (ResolverState, a) +runPathResolver :: (Members '[TaggedLock, Reader EntryPoint, Files, Error JuvixError, Error DependencyError, GitClone, EvalFileEff] r) => Path Abs Dir -> Sem (PathResolver ': r) a -> Sem r (ResolverState, a) runPathResolver = runPathResolver' iniResolverState -runPathResolver' :: (Members '[Reader ImportScanStrategy, TaggedLock, Reader EntryPoint, Files, Error JuvixError, Error DependencyError, GitClone, EvalFileEff] r) => ResolverState -> Path Abs Dir -> Sem (PathResolver ': r) a -> Sem r (ResolverState, a) +runPathResolver' :: (Members '[TaggedLock, Reader EntryPoint, Files, Error JuvixError, Error DependencyError, GitClone, EvalFileEff] r) => ResolverState -> Path Abs Dir -> Sem (PathResolver ': r) a -> Sem r (ResolverState, a) runPathResolver' st root x = do e <- ask let _envSingleFile :: Maybe (Path Abs File) @@ -564,15 +564,15 @@ runPathResolver' st root x = do } runPathResolver2 st env x -runPathResolverPipe' :: (Members '[Reader ImportScanStrategy, TaggedLock, Files, Reader EntryPoint, Error DependencyError, GitClone, Error JuvixError, EvalFileEff] r) => ResolverState -> Sem (PathResolver ': r) a -> Sem r (ResolverState, a) +runPathResolverPipe' :: (Members '[TaggedLock, Files, Reader EntryPoint, Error DependencyError, GitClone, Error JuvixError, EvalFileEff] r) => ResolverState -> Sem (PathResolver ': r) a -> Sem r (ResolverState, a) runPathResolverPipe' iniState a = do r <- asks (^. entryPointResolverRoot) runPathResolver' iniState r a -runPathResolverPipe :: (Members '[Reader ImportScanStrategy, TaggedLock, Files, Reader EntryPoint, Error DependencyError, GitClone, Error JuvixError, EvalFileEff] r) => Sem (PathResolver ': r) a -> Sem r (ResolverState, a) +runPathResolverPipe :: (Members '[TaggedLock, Files, Reader EntryPoint, Error DependencyError, GitClone, Error JuvixError, EvalFileEff] r) => Sem (PathResolver ': r) a -> Sem r (ResolverState, a) runPathResolverPipe a = do r <- asks (^. entryPointResolverRoot) runPathResolver r a -evalPathResolverPipe :: (Members '[Reader ImportScanStrategy, TaggedLock, Files, Reader EntryPoint, Error DependencyError, GitClone, Error JuvixError, EvalFileEff] r) => Sem (PathResolver ': r) a -> Sem r a +evalPathResolverPipe :: (Members '[TaggedLock, Files, Reader EntryPoint, Error DependencyError, GitClone, Error JuvixError, EvalFileEff] r) => Sem (PathResolver ': r) a -> Sem r a evalPathResolverPipe = fmap snd . runPathResolverPipe diff --git a/src/Juvix/Compiler/Pipeline/Package/Loader/EvalEff/IO.hs b/src/Juvix/Compiler/Pipeline/Package/Loader/EvalEff/IO.hs index c77595e5bd..d64b78275e 100644 --- a/src/Juvix/Compiler/Pipeline/Package/Loader/EvalEff/IO.hs +++ b/src/Juvix/Compiler/Pipeline/Package/Loader/EvalEff/IO.hs @@ -7,7 +7,6 @@ where import Data.HashMap.Strict qualified as HashMap import Juvix.Compiler.Concrete hiding (Symbol) import Juvix.Compiler.Concrete.Translation.FromSource.TopModuleNameChecker (runTopModuleNameChecker) -import Juvix.Compiler.Concrete.Translation.ImportScanner (defaultImportScanStrategy) import Juvix.Compiler.Core (CoreResult, coreResultModule) import Juvix.Compiler.Core qualified as Core import Juvix.Compiler.Core.Evaluator @@ -141,7 +140,6 @@ loadPackage' packagePath = do . mapError (JuvixError @GitProcessError) . runGitProcess . runEvalFileEffIO - . runReader defaultImportScanStrategy . runPackagePathResolver rootPath . runTopModuleNameChecker . evalModuleInfoCache diff --git a/src/Juvix/Compiler/Pipeline/Package/Loader/PathResolver.hs b/src/Juvix/Compiler/Pipeline/Package/Loader/PathResolver.hs index f315e8c003..5b412ffb7b 100644 --- a/src/Juvix/Compiler/Pipeline/Package/Loader/PathResolver.hs +++ b/src/Juvix/Compiler/Pipeline/Package/Loader/PathResolver.hs @@ -2,7 +2,6 @@ module Juvix.Compiler.Pipeline.Package.Loader.PathResolver where import Data.HashSet qualified as HashSet import Juvix.Compiler.Concrete hiding (Symbol) -import Juvix.Compiler.Concrete.Translation.ImportScanner import Juvix.Compiler.Core.Language import Juvix.Compiler.Pipeline.EntryPoint import Juvix.Compiler.Pipeline.Loader.PathResolver @@ -32,7 +31,7 @@ makeLenses ''RootInfoFiles -- package and global standard library (currently under global-package/.juvix-build) runPackagePathResolver :: forall r a. - (Members '[Reader ImportScanStrategy, TaggedLock, Error JuvixError, Files, EvalFileEff, Reader EntryPoint] r) => + (Members '[TaggedLock, Error JuvixError, Files, EvalFileEff, Reader EntryPoint] r) => Path Abs Dir -> Sem (PathResolver ': r) a -> Sem r a @@ -181,7 +180,7 @@ runPackagePathResolver rootPath sem = do } runPackagePathResolver' :: - (Members '[Reader ImportScanStrategy, TaggedLock, Error JuvixError, Files, EvalFileEff, Reader EntryPoint] r) => + (Members '[TaggedLock, Error JuvixError, Files, EvalFileEff, Reader EntryPoint] r) => Path Abs Dir -> Sem (PathResolver ': r) a -> Sem r (ResolverState, a) @@ -189,5 +188,5 @@ runPackagePathResolver' root eff = do res <- runPackagePathResolver root eff return (iniResolverState, res) -runPackagePathResolver'' :: (Members '[Reader ImportScanStrategy, Reader EntryPoint, TaggedLock, Error JuvixError, Files, EvalFileEff] r) => Path Abs Dir -> ResolverState -> Sem (PathResolver ': r) a -> Sem r (ResolverState, a) +runPackagePathResolver'' :: (Members '[Reader EntryPoint, TaggedLock, Error JuvixError, Files, EvalFileEff] r) => Path Abs Dir -> ResolverState -> Sem (PathResolver ': r) a -> Sem r (ResolverState, a) runPackagePathResolver'' root _ eff = runPackagePathResolver' root eff diff --git a/src/Juvix/Compiler/Pipeline/Repl.hs b/src/Juvix/Compiler/Pipeline/Repl.hs index 558737e02b..c05b8f3404 100644 --- a/src/Juvix/Compiler/Pipeline/Repl.hs +++ b/src/Juvix/Compiler/Pipeline/Repl.hs @@ -6,7 +6,6 @@ import Juvix.Compiler.Concrete.Translation.FromParsed qualified as Scoper import Juvix.Compiler.Concrete.Translation.FromSource qualified as Parser import Juvix.Compiler.Concrete.Translation.FromSource.ParserResultBuilder (runParserResultBuilder) import Juvix.Compiler.Concrete.Translation.FromSource.TopModuleNameChecker (runTopModuleNameChecker) -import Juvix.Compiler.Concrete.Translation.ImportScanner (defaultImportScanStrategy) import Juvix.Compiler.Core qualified as Core import Juvix.Compiler.Core.Transformation qualified as Core import Juvix.Compiler.Core.Transformation.DisambiguateNames (disambiguateNames) @@ -166,7 +165,6 @@ compileReplInputIO fp txt = do . mapError (JuvixError @DependencyError) . mapError (JuvixError @PackageLoaderError) . runEvalFileEffIO - . runReader defaultImportScanStrategy . runPathResolverArtifacts . runTopModuleNameChecker . evalModuleInfoCache diff --git a/src/Juvix/Compiler/Pipeline/Run.hs b/src/Juvix/Compiler/Pipeline/Run.hs index fee8534824..84538ac3e7 100644 --- a/src/Juvix/Compiler/Pipeline/Run.hs +++ b/src/Juvix/Compiler/Pipeline/Run.hs @@ -11,7 +11,6 @@ import Juvix.Compiler.Concrete.Translation.FromParsed.Analysis.Scoping qualified import Juvix.Compiler.Concrete.Translation.FromParsed.Analysis.Scoping qualified as Scoper import Juvix.Compiler.Concrete.Translation.FromSource qualified as P import Juvix.Compiler.Concrete.Translation.FromSource.TopModuleNameChecker (runTopModuleNameChecker) -import Juvix.Compiler.Concrete.Translation.ImportScanner (defaultImportScanStrategy) import Juvix.Compiler.Core.Data.Module qualified as Core import Juvix.Compiler.Core.Translation.FromInternal.Data qualified as Core import Juvix.Compiler.Internal.Translation qualified as Internal @@ -83,7 +82,6 @@ runIOEitherPipeline' entry a = do . mapError (JuvixError @DependencyError) . mapError (JuvixError @PackageLoaderError) . runEvalFileEffIO - . runReader defaultImportScanStrategy . runPathResolver' . runTopModuleNameChecker . evalModuleInfoCache @@ -154,7 +152,6 @@ runReplPipelineIOEither' lockMode entry = do . mapError (JuvixError @DependencyError) . mapError (JuvixError @PackageLoaderError) . runEvalFileEffIO - . runReader defaultImportScanStrategy . runPathResolver' . runTopModuleNameChecker . evalModuleInfoCache