Skip to content

Commit

Permalink
Fix after merge
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszcz committed Dec 14, 2023
1 parent 0ae4460 commit 7cd72fb
Show file tree
Hide file tree
Showing 18 changed files with 63 additions and 1,131 deletions.
35 changes: 15 additions & 20 deletions app/App.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Data.ByteString qualified as ByteString
import GlobalOptions
import Juvix.Compiler.Internal.Translation.FromInternal.Analysis.Termination.Checker
import Juvix.Compiler.Pipeline.Loader.PathResolver
import Juvix.Compiler.Pipeline.Root
import Juvix.Compiler.Pipeline.Run
import Juvix.Compiler.Store.Language qualified as Store
import Juvix.Data.Error qualified as Error
Expand All @@ -30,9 +31,6 @@ data App m a where
GetMainFile :: Maybe (AppPath File) -> App m (Path Abs File)
FromAppPathDir :: AppPath Dir -> App m (Path Abs Dir)
RenderStdOut :: (HasAnsiBackend a, HasTextBackend a) => a -> App m ()
RunPipelineEither :: AppPath File -> Sem PipelineEff a -> App m (Either JuvixError (ResolverState, (a, Store.ModuleTable)))
RunPipelineNoFileEither :: Sem PipelineEff a -> App m (Either JuvixError (ResolverState, (a, Store.ModuleTable)))
RunPipelineSetupEither :: Sem PipelineEff' a -> App m (Either JuvixError (ResolverState, a))
RunCorePipelineEither :: AppPath File -> App m (Either JuvixError Artifacts)
Say :: Text -> App m ()
SayRaw :: ByteString -> App m ()
Expand Down Expand Up @@ -82,15 +80,6 @@ reAppIO args@RunAppIOArgs {..} =
RunCorePipelineEither input -> do
entry <- getEntryPoint' args input
embed (corePipelineIOEither entry)
RunPipelineEither input p -> do
entry <- embed (getEntryPoint' args input)
embed (runIOEither entry p)
RunPipelineNoFileEither p -> do
entry <- embed (getEntryPointStdin' args)
embed (runIOEither entry p)
RunPipelineSetupEither p -> do
entry <- embed (getEntryPointStdin' args)
embed (runIOEitherPipeline entry p)
Say t
| g ^. globalOnlyErrors -> return ()
| otherwise -> embed (putStrLn t)
Expand Down Expand Up @@ -141,17 +130,23 @@ getEntryPoint' RunAppIOArgs {..} inputFile = do
| otherwise -> return Nothing
set entryPointStdin estdin <$> entryPointFromGlobalOptionsPre root (inputFile ^. pathPath) opts

runPipelineNoFileEither :: (Members '[Embed IO, TaggedLock, App] r) => Sem (PipelineEff r) a -> Sem r (Either JuvixError (ResolverState, a))
runPipelineNoFileEither :: (Members '[Embed IO, TaggedLock, App] r) => Sem (PipelineEff r) a -> Sem r (Either JuvixError (ResolverState, (a, Store.ModuleTable)))
runPipelineNoFileEither p = do
args <- askArgs
entry <- getEntryPointStdin' args
snd <$> runIOEither entry p
runIOEither entry p

runPipelineEither :: (Members '[Embed IO, TaggedLock, App] r) => AppPath File -> Sem (PipelineEff r) a -> Sem r (Either JuvixError (ResolverState, a))
runPipelineEither :: (Members '[Embed IO, TaggedLock, App] r) => AppPath File -> Sem (PipelineEff r) a -> Sem r (Either JuvixError (ResolverState, (a, Store.ModuleTable)))
runPipelineEither input p = do
args <- askArgs
entry <- getEntryPoint' args input
snd <$> runIOEither entry p
runIOEither entry p

runPipelineSetupEither :: (Members '[Embed IO, TaggedLock, App] r) => Sem (PipelineEff' r) a -> Sem r (Either JuvixError (ResolverState, a))
runPipelineSetupEither p = do
args <- askArgs
entry <- getEntryPointStdin' args
runIOEitherPipeline entry p

getEntryPointStdin' :: (Members '[Embed IO, TaggedLock] r) => RunAppIOArgs -> Sem r EntryPoint
getEntryPointStdin' RunAppIOArgs {..} = do
Expand Down Expand Up @@ -182,13 +177,13 @@ getEntryPoint inputFile = do
_runAppIOArgsRoot <- askRoot
getEntryPoint' (RunAppIOArgs {..}) inputFile

getEntryPointStdin :: (Members '[Embed IO, App] r) => Sem r EntryPoint
getEntryPointStdin :: (Members '[Embed IO, App, TaggedLock] r) => Sem r EntryPoint
getEntryPointStdin = do
_runAppIOArgsGlobalOptions <- askGlobalOptions
_runAppIOArgsRoot <- askRoot
embed (getEntryPointStdin' (RunAppIOArgs {..}))
getEntryPointStdin' (RunAppIOArgs {..})

runPipelineTermination :: (Member App r) => AppPath File -> Sem (Termination ': PipelineEff) a -> Sem r (a, Store.ModuleTable)
runPipelineTermination :: (Members '[Embed IO, App, TaggedLock] r) => AppPath File -> Sem (Termination ': PipelineEff r) a -> Sem r (a, Store.ModuleTable)
runPipelineTermination input p = do
r <- runPipelineEither input (evalTermination iniTerminationState p)
case r of
Expand All @@ -209,7 +204,7 @@ runPipelineNoFile p = do
Left err -> exitJuvixError err
Right res -> return (fst $ snd res)

runPipelineSetup :: (Member App r) => Sem PipelineEff' a -> Sem r a
runPipelineSetup :: (Members '[App, Embed IO, TaggedLock] r) => Sem (PipelineEff' r) a -> Sem r a
runPipelineSetup p = do
r <- runPipelineSetupEither p
case r of
Expand Down
2 changes: 1 addition & 1 deletion app/Commands/Dependencies/Update.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import Commands.Base
import Juvix.Compiler.Pipeline.Loader.PathResolver
import Juvix.Compiler.Pipeline.Setup

runCommand :: (Members '[Embed IO, App] r) => Sem r ()
runCommand :: (Members '[Embed IO, TaggedLock, App] r) => Sem r ()
runCommand = runPipelineSetup (entrySetup (set dependenciesConfigForceUpdateLockfile True defaultDependenciesConfig))
12 changes: 0 additions & 12 deletions app/Commands/Dev/Internal/Arity.hs

This file was deleted.

12 changes: 0 additions & 12 deletions app/Commands/Dev/Internal/Reachability.hs

This file was deleted.

15 changes: 0 additions & 15 deletions app/Commands/Dev/Internal/Reachability/Options.hs

This file was deleted.

2 changes: 1 addition & 1 deletion app/GlobalOptions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import CommonOptions
import Juvix.Compiler.Core.Options qualified as Core
import Juvix.Compiler.Internal.Pretty.Options qualified as Internal
import Juvix.Compiler.Pipeline
import Juvix.Compiler.Pipeline.Package (readPackageRootIO)
import Juvix.Compiler.Pipeline.Root
import Juvix.Data.Effect.TaggedLock
import Juvix.Data.Error.GenericError qualified as E

Expand Down
2 changes: 0 additions & 2 deletions src/Juvix/Compiler/Backend/Html/Translation/FromTyped.hs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ genJudocHtml entry JudocArgs {..} =
mkComments $
_judocArgsCtx
^. InternalTyped.resultInternal
. InternalArity.resultInternal
. Internal.resultScoper
. Scoped.resultParserResult
. Parser.resultParserState
Expand All @@ -181,7 +180,6 @@ genJudocHtml entry JudocArgs {..} =
mainMod =
_judocArgsCtx
^. InternalTyped.resultInternal
. InternalArity.resultInternal
. Internal.resultScoper
. Scoped.mainModule

Expand Down
47 changes: 4 additions & 43 deletions src/Juvix/Compiler/Internal/Translation/FromInternal.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module Juvix.Compiler.Internal.Translation.FromInternal
( typeChecking,
typeCheckingNew,
( typeCheckingNew,
typeCheckExpression,
typeCheckExpressionType,
typeCheckImport,
Expand All @@ -9,9 +8,9 @@ where

import Data.HashMap.Strict qualified as HashMap
import Juvix.Compiler.Concrete.Data.Highlight.Input
import Juvix.Compiler.Internal.Data.LocalVars
import Juvix.Compiler.Internal.Language
import Juvix.Compiler.Internal.Translation.FromConcrete.Data.Context as Internal
import Juvix.Compiler.Internal.Translation.FromInternal.Analysis.Reachability
import Juvix.Compiler.Internal.Translation.FromInternal.Analysis.Termination.Checker
import Juvix.Compiler.Internal.Translation.FromInternal.Analysis.TypeChecking
import Juvix.Compiler.Pipeline.Artifacts
Expand Down Expand Up @@ -50,37 +49,6 @@ typeCheckExpression exp = (^. typedExpression) <$> typeCheckExpressionType exp
typeCheckImport :: Import -> Sem r Import
typeCheckImport = return

typeChecking ::
forall r.
(Members '[Reader EntryPoint, Error JuvixError, NameIdGen, Reader ModuleTable] r) =>
Sem (Termination ': r) ArityChecking.InternalArityResult ->
Sem r InternalTypedResult
typeChecking a = do
(termin, (res, (normalized, (idens, (funs, r))))) <- runTermination iniTerminationState $ do
res <- a
itab <- getInternalModuleTable <$> ask
let md :: InternalModule
md = res ^. ArityChecking.resultInternalModule
table :: InfoTable
table = computeCombinedInfoTable (insertInternalModule itab md)
fmap (res,)
. runOutputList
. runState (computeTypesTable itab)
. runState (computeFunctionsTable itab)
. runReader table
. mapError (JuvixError @TypeCheckerError)
$ checkTable >> checkModule (res ^. ArityChecking.resultModule)
return
InternalTypedResult
{ _resultInternal = res,
_resultModule = r,
_resultInternalModule = computeInternalModule idens funs r,
_resultTermination = termin,
_resultNormalized = HashMap.fromList [(e ^. exampleId, e ^. exampleExpression) | e <- normalized],
_resultIdenTypes = idens,
_resultFunctions = funs
}

typeCheckingNew ::
forall r.
(Members '[Reader EntryPoint, Error JuvixError, NameIdGen, Reader ModuleTable] r) =>
Expand All @@ -100,18 +68,11 @@ typeCheckingNew a = do
. runState (mempty :: FunctionsTable)
. runReader table
. mapError (JuvixError @TypeCheckerError)
$ checkTable >> New.checkModule (res ^. Internal.resultModule)
$ checkTable >> checkModule (res ^. Internal.resultModule)
let md = computeInternalModule idens funs r
ariRes :: InternalArityResult
ariRes =
InternalArityResult
{ _resultInternal = res,
_resultModule = res ^. Internal.resultModule,
_resultInternalModule = md
}
return
InternalTypedResult
{ _resultInternal = ariRes,
{ _resultInternal = res,
_resultModule = r,
_resultInternalModule = md,
_resultTermination = termin,
Expand Down
Loading

0 comments on commit 7cd72fb

Please sign in to comment.