on master help sign in
Main.hs: drop unused imports, minor readability improvements
commite1659e38e6bbd8eb32f2ac2802a57442be75579f authorHeather <heather@live.ru> dateFri 26 Feb 2016, 12:04 (11 years ago) parentfdb04af
1 file changed+41−44
main/Main.hs+41−44
main/Main.hs+41−44
@@ -4,12 +4,10 @@ import System.Console.Haskeline
44import System.IO
55import System.Environment
66import System.Exit
7−import System.FilePath ((</>), addTrailingPathSeparator)
87import System.Directory
98
109import Data.Maybe
1110import Data.Version
12−import Control.Monad.Trans.State.Strict ( execStateT, get, put )
1311import Control.Monad ( when )
1412
1513import Idris.Core.TT
@@ -44,66 +42,65 @@ main = do opts <- runArgParser
4442
4543runIdris :: [Opt] -> Idris ()
4644runIdris opts = do
47− runIO setupBundledCC
48− when (ShowLoggingCats `elem` opts) $ runIO showLoggingCats
49− when (ShowIncs `elem` opts) $ runIO showIncs
50− when (ShowLibs `elem` opts) $ runIO showLibs
51− when (ShowLibdir `elem` opts) $ runIO showLibdir
52− when (ShowPkgs `elem` opts) $ runIO showPkgs
53− case opt getClient opts of
54− [] -> return ()
55− (c:_) -> do setVerbose False
56− setQuiet True
57− runIO $ runClient (getPort opts) c
58− runIO $ exitWith ExitSuccess
59− case opt getPkgCheck opts of
60− [] -> return ()
61− fs -> do runIO $ mapM_ (checkPkg (WarnOnly `elem` opts) True) fs
62− runIO $ exitWith ExitSuccess
63− case opt getPkgClean opts of
64− [] -> return ()
65− fs -> do runIO $ mapM_ cleanPkg fs
66− runIO $ exitWith ExitSuccess
67− case opt getPkgMkDoc opts of -- IdrisDoc
68− [] -> return ()
69− fs -> do runIO $ mapM_ documentPkg fs
70− runIO $ exitWith ExitSuccess
71− case opt getPkgTest opts of
72− [] -> return ()
73− fs -> do runIO $ mapM_ testPkg fs
74− runIO $ exitWith ExitSuccess
75− case opt getPkg opts of
76− [] -> case opt getPkgREPL opts of
77− [] -> idrisMain opts
78− [f] -> replPkg f
79− _ -> ifail "Too many packages"
80− fs -> runIO $ mapM_ (buildPkg (WarnOnly `elem` opts)) fs
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
8179
8280showver :: IO b
8381showver = do putStrLn $ "Idris version " ++ ver
84− exitWith ExitSuccess
82+ exitSuccess
8583
8684showLibs :: IO b
8785showLibs = do libFlags <- getLibFlags
8886 putStrLn $ unwords libFlags
89− exitWith ExitSuccess
87+ exitSuccess
9088
9189showLibdir :: IO b
92−showLibdir = do dir <- getIdrisLibDir
93− putStrLn dir
94− exitWith ExitSuccess
90+showLibdir = do putStrLn =<< getIdrisLibDir
91+ exitSuccess
9592
9693showIncs :: IO b
9794showIncs = do incFlags <- getIncFlags
9895 putStrLn $ unwords incFlags
99− exitWith ExitSuccess
96+ exitSuccess
10097
10198-- | List idris packages installed
10299showPkgs :: IO b
103100showPkgs = do mapM putStrLn =<< installedPackages
104− exitWith ExitSuccess
101+ exitSuccess
105102
106103showLoggingCats :: IO b
107104showLoggingCats = do
108105 putStrLn loggingCatsStr
109− exitWith ExitSuccess
106+ exitSuccess