Skip to content

Commit

Permalink
remove unused Reader ImportScanStrategy from pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
janmasrovira committed May 3, 2024
1 parent ab431ba commit 066a83c
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 41 deletions.
25 changes: 12 additions & 13 deletions app/Commands/Dev/ImportTree/Print.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
3 changes: 1 addition & 2 deletions src/Juvix/Compiler/Pipeline.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
5 changes: 2 additions & 3 deletions src/Juvix/Compiler/Pipeline/Artifacts/PathResolver.hs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
24 changes: 12 additions & 12 deletions src/Juvix/Compiler/Pipeline/Loader/PathResolver.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 ->
Expand Down Expand Up @@ -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
Expand All @@ -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 ->
Expand Down Expand Up @@ -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 ->
Expand Down Expand Up @@ -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)
Expand All @@ -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
2 changes: 0 additions & 2 deletions src/Juvix/Compiler/Pipeline/Package/Loader/EvalEff/IO.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -141,7 +140,6 @@ loadPackage' packagePath = do
. mapError (JuvixError @GitProcessError)
. runGitProcess
. runEvalFileEffIO
. runReader defaultImportScanStrategy
. runPackagePathResolver rootPath
. runTopModuleNameChecker
. evalModuleInfoCache
Expand Down
7 changes: 3 additions & 4 deletions src/Juvix/Compiler/Pipeline/Package/Loader/PathResolver.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -181,13 +180,13 @@ 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)
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
2 changes: 0 additions & 2 deletions src/Juvix/Compiler/Pipeline/Repl.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -166,7 +165,6 @@ compileReplInputIO fp txt = do
. mapError (JuvixError @DependencyError)
. mapError (JuvixError @PackageLoaderError)
. runEvalFileEffIO
. runReader defaultImportScanStrategy
. runPathResolverArtifacts
. runTopModuleNameChecker
. evalModuleInfoCache
Expand Down
3 changes: 0 additions & 3 deletions src/Juvix/Compiler/Pipeline/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -83,7 +82,6 @@ runIOEitherPipeline' entry a = do
. mapError (JuvixError @DependencyError)
. mapError (JuvixError @PackageLoaderError)
. runEvalFileEffIO
. runReader defaultImportScanStrategy
. runPathResolver'
. runTopModuleNameChecker
. evalModuleInfoCache
Expand Down Expand Up @@ -154,7 +152,6 @@ runReplPipelineIOEither' lockMode entry = do
. mapError (JuvixError @DependencyError)
. mapError (JuvixError @PackageLoaderError)
. runEvalFileEffIO
. runReader defaultImportScanStrategy
. runPathResolver'
. runTopModuleNameChecker
. evalModuleInfoCache
Expand Down

0 comments on commit 066a83c

Please sign in to comment.