on 4e4b7df help sign in
Idris-dev/main/Main.hs
106 lines 2.9 kB history raw
1module Main where
3import System.Console.Haskeline
4import System.IO
5import System.Environment
6import System.Exit
7import System.Directory
9import Data.Maybe
10import Data.Version
11import Control.Monad ( when )
13import Idris.Core.TT
14import Idris.Core.Typecheck
15import Idris.Core.Evaluate
16import Idris.Core.Constraints
18import Idris.AbsSyntax
19import Idris.Parser
20import Idris.REPL
21import Idris.ElabDecls
22import Idris.Primitives
23import Idris.Imports
24import Idris.Error
25import Idris.CmdOptions
27import IRTS.System ( getLibFlags, getIdrisLibDir, getIncFlags )
29import Util.DynamicLinker
30import Util.System
32import Pkg.Package
34import Paths_idris
36-- Main program reads command line options, parses the main program, and gets
37-- on with the REPL.
39main :: IO ()
40main = do opts <- runArgParser
41 runMain (runIdris opts)
43runIdris :: [Opt] -> Idris ()
44runIdris opts = do
45 runIO setupBundledCC
46 when (ShowLoggingCats `elem` opts) $ runIO showLoggingCats
47 when (ShowIncs `elem` opts) $ runIO showIncs
48 when (ShowLibs `elem` opts) $ runIO showLibs
49 when (ShowLibdir `elem` opts) $ runIO showLibdir
50 when (ShowPkgs `elem` opts) $ runIO showPkgs
51 case opt getClient opts of
52 [] -> return ()
53 (c:_) -> do setVerbose False
54 setQuiet True
55 runIO $ runClient (getPort opts) c
56 runIO exitSuccess
57 case opt getPkgCheck opts of
58 [] -> return ()
59 fs -> do runIO $ mapM_ (checkPkg (WarnOnly `elem` opts) True) fs
60 runIO exitSuccess
61 case opt getPkgClean opts of
62 [] -> return ()
63 fs -> do runIO $ mapM_ cleanPkg fs
64 runIO exitSuccess
65 case opt getPkgMkDoc opts of -- IdrisDoc
66 [] -> return ()
67 fs -> do runIO $ mapM_ documentPkg fs
68 runIO exitSuccess
69 case opt getPkgTest opts of
70 [] -> return ()
71 fs -> do runIO $ mapM_ testPkg fs
72 runIO exitSuccess
73 case opt getPkg opts of
74 [] -> case opt getPkgREPL opts of
75 [] -> idrisMain opts
76 [f] -> replPkg f
77 _ -> ifail "Too many packages"
78 fs -> runIO $ mapM_ (buildPkg (WarnOnly `elem` opts)) fs
80showver :: IO b
81showver = do putStrLn $ "Idris version " ++ ver
82 exitSuccess
84showLibs :: IO b
85showLibs = do libFlags <- getLibFlags
86 putStrLn $ unwords libFlags
87 exitSuccess
89showLibdir :: IO b
90showLibdir = do putStrLn =<< getIdrisLibDir
91 exitSuccess
93showIncs :: IO b
94showIncs = do incFlags <- getIncFlags
95 putStrLn $ unwords incFlags
96 exitSuccess
98-- | List idris packages installed
99showPkgs :: IO b
100showPkgs = do mapM putStrLn =<< installedPackages
101 exitSuccess
103showLoggingCats :: IO b
104showLoggingCats = do
105 putStrLn loggingCatsStr
106 exitSuccess