@@ -69,9 +69,10 @@ buildPkg warnonly (install, fp)
69-- This differs from build in that executables are not built, if the
69-- This differs from build in that executables are not built, if the
70-- package contains an executable.
70-- package contains an executable.
71checkPkg :: Bool -- ^ Show Warnings
71checkPkg :: Bool -- ^ Show Warnings
72+ -> Bool -- ^ quit on failure
72 -> FilePath -- ^ Path to ipkg file.
73 -> FilePath -- ^ Path to ipkg file.
74−checkPkg warnonly fpath
75+checkPkg warnonly quit fpath
75 = do pkgdesc <-parseDesc fpath
76 = do pkgdesc <-parseDesc fpath
76 ok <- mapM (testLib warnonly (pkgname pkgdesc)) (libdeps pkgdesc)
77 ok <- mapM (testLib warnonly (pkgname pkgdesc)) (libdeps pkgdesc)
77 when (and ok) $
78 when (and ok) $
@@ -81,12 +82,31 @@ checkPkg warnonly fpath
81 res <- buildMods (NoREPL : Verbose : idris_opts pkgdesc)
82 res <- buildMods (NoREPL : Verbose : idris_opts pkgdesc)
82 (modules pkgdesc)
83 (modules pkgdesc)
83 setCurrentDirectory dir
84 setCurrentDirectory dir
84− case res of
85+ when quit $ case res of
85− Nothing -> exitWith (ExitFailure 1)
86+ Nothing -> exitWith (ExitFailure 1)
86− Just res' -> do
87+ Just res' -> do
87− case errLine res' of
88+ case errLine res' of
88− Just _ -> exitWith (ExitFailure 1)
89+ Just _ -> exitWith (ExitFailure 1)
89− _ -> return ()
90+ _ -> return ()
92+-- | Check a package and start a REPL
93+replPkg :: FilePath -> Idris ()
94+replPkg fp = do orig <- getIState
95+ runIO $ checkPkg False False fp
96+ pkgdesc <- runIO $ parseDesc fp -- bzzt, repetition!
97+ let opts = idris_opts pkgdesc
98+ let mod = idris_main pkgdesc
99+ let f = toPath (showCG mod)
101+ dir <- runIO $ getCurrentDirectory
102+ runIO $ setCurrentDirectory $ dir </> sourcedir pkgdesc
105+ then idrisMain ((Filename f) : opts)
106+ else iputStrLn "Can't start REPL: no main module given"
107+ runIO $ setCurrentDirectory dir
109+ where toPath n = foldl1' (</>) $ splitOn "." n
91-- | Clean Package build files
111-- | Clean Package build files
92cleanPkg :: FilePath -- ^ Path to ipkg file.
112cleanPkg :: FilePath -- ^ Path to ipkg file.