mirror of
https://github.com/anoma/juvix.git
synced 2024-12-18 12:21:46 +03:00
69594edc7b
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.
36 lines
1.1 KiB
Haskell
36 lines
1.1 KiB
Haskell
{-# LANGUAGE QuasiQuotes #-}
|
|
|
|
module Main (main) where
|
|
|
|
import App
|
|
import CommonOptions
|
|
import Data.String.Interpolate (i)
|
|
import GlobalOptions
|
|
import Juvix.Compiler.Pipeline.Root
|
|
import TopCommand
|
|
import TopCommand.Options
|
|
|
|
main :: IO ()
|
|
main = do
|
|
let parserPreferences = prefs showHelpOnEmpty
|
|
invokeDir <- getCurrentDir
|
|
(_runAppIOArgsGlobalOptions, cli) <- customExecParser parserPreferences descr
|
|
mbuildDir <- mapM (prepathToAbsDir invokeDir) (_runAppIOArgsGlobalOptions ^? globalBuildDir . _Just . pathPath)
|
|
mainFile <- topCommandInputPath cli
|
|
mapM_ checkMainFile mainFile
|
|
runFinal
|
|
. resourceToIOFinal
|
|
. embedToFinal @IO
|
|
. runTaggedLockPermissive
|
|
$ do
|
|
_runAppIOArgsRoot <- findRootAndChangeDir (containingDir <$> mainFile) mbuildDir invokeDir
|
|
runAppIO RunAppIOArgs {..} (runTopCommand cli)
|
|
where
|
|
checkMainFile :: SomePath b -> IO ()
|
|
checkMainFile p = unlessM (doesSomePathExist p) err
|
|
where
|
|
err :: IO ()
|
|
err = do
|
|
hPutStrLn stderr [i|The input path #{p} does not exist|]
|
|
exitFailure
|