1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-22 14:21:30 +03:00
juvix/app/Commands/Repl/Base.hs
Jan Mas Rovira 69594edc7b
Read Package on demand and cache it (#2548)
This patch dramatically increases the efficiency of `juvix dev root`,
which was unnecessarily parsing all dependencies included in the
`Package.juvix` file. Other commands that do not require the `Package`
will also be faster.

It also refactors some functions so that the `TaggedLock` effect is run
globally.

I've added `singletons-base` as a dependency so we can have `++` on the
type level. We've tried to define a type family ourselves but inference
was not working properly.
2023-12-06 18:24:59 +01:00

36 lines
861 B
Haskell

module Commands.Repl.Base where
import Commands.Base hiding
( command,
)
import Commands.Repl.Options
import Control.Monad.Except qualified as Except
import Control.Monad.Reader qualified as Reader
import Control.Monad.State.Strict qualified as State
import System.Console.Repline
type ReplS = Reader.ReaderT ReplEnv (State.StateT ReplState (Except.ExceptT JuvixError IO))
type Repl a = HaskelineT ReplS a
data ReplContext = ReplContext
{ _replContextArtifacts :: Artifacts,
_replContextEntryPoint :: EntryPoint
}
data ReplEnv = ReplEnv
{ _replRoot :: Root,
_replPackage :: Package,
_replOptions :: ReplOptions
}
data ReplState = ReplState
{ _replStateRoot :: Root,
_replStateContext :: Maybe ReplContext,
_replStateGlobalOptions :: GlobalOptions
}
makeLenses ''ReplState
makeLenses ''ReplContext
makeLenses ''ReplEnv