creating src/Boot.hs.
This commit is contained in:
parent
e4f4ef52c0
commit
064e4af236
@ -88,7 +88,8 @@ Library
|
|||||||
Executable ghc-mod
|
Executable ghc-mod
|
||||||
Default-Language: Haskell2010
|
Default-Language: Haskell2010
|
||||||
Main-Is: GHCMod.hs
|
Main-Is: GHCMod.hs
|
||||||
Other-Modules: Paths_ghc_mod
|
Other-Modules: Boot
|
||||||
|
Paths_ghc_mod
|
||||||
GHC-Options: -Wall
|
GHC-Options: -Wall
|
||||||
HS-Source-Dirs: src
|
HS-Source-Dirs: src
|
||||||
Build-Depends: base >= 4.0 && < 5
|
Build-Depends: base >= 4.0 && < 5
|
||||||
@ -100,7 +101,8 @@ Executable ghc-mod
|
|||||||
Executable ghc-modi
|
Executable ghc-modi
|
||||||
Default-Language: Haskell2010
|
Default-Language: Haskell2010
|
||||||
Main-Is: GHCModi.hs
|
Main-Is: GHCModi.hs
|
||||||
Other-Modules: Paths_ghc_mod
|
Other-Modules: Boot
|
||||||
|
Paths_ghc_mod
|
||||||
GHC-Options: -Wall
|
GHC-Options: -Wall
|
||||||
HS-Source-Dirs: src
|
HS-Source-Dirs: src
|
||||||
Build-Depends: base >= 4.0 && < 5
|
Build-Depends: base >= 4.0 && < 5
|
||||||
|
42
src/Boot.hs
Normal file
42
src/Boot.hs
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
module Boot where
|
||||||
|
|
||||||
|
import Language.Haskell.GhcMod
|
||||||
|
import Control.Applicative ((<$>))
|
||||||
|
|
||||||
|
boot :: Options -> Cradle -> IO String
|
||||||
|
boot opt cradle = do
|
||||||
|
mods <- listModules opt cradle
|
||||||
|
langs <- listLanguages opt
|
||||||
|
flags <- listFlags opt
|
||||||
|
let opt' = addPackages opt
|
||||||
|
pre <- concat <$> mapM (browseModule opt' cradle) preBrowsedModules
|
||||||
|
return $ mods ++ langs ++ flags ++ pre
|
||||||
|
|
||||||
|
preBrowsedModules :: [String]
|
||||||
|
preBrowsedModules = [
|
||||||
|
"Prelude"
|
||||||
|
, "Control.Applicative"
|
||||||
|
, "Control.Exception"
|
||||||
|
, "Control.Monad"
|
||||||
|
, "Data.ByteString"
|
||||||
|
, "Data.Char"
|
||||||
|
, "Data.List"
|
||||||
|
, "Data.Maybe"
|
||||||
|
, "System.Directory"
|
||||||
|
, "System.FilePath"
|
||||||
|
, "System.IO"
|
||||||
|
]
|
||||||
|
|
||||||
|
preBrowsePackages :: [String]
|
||||||
|
preBrowsePackages = [
|
||||||
|
"bytestring"
|
||||||
|
, "directory"
|
||||||
|
, "filepath"
|
||||||
|
]
|
||||||
|
|
||||||
|
addPackages :: Options -> Options
|
||||||
|
addPackages opt = opt { ghcOpts = pkgs ++ ghcOpts opt}
|
||||||
|
where
|
||||||
|
pkgs = map ("-package " ++) preBrowsePackages
|
||||||
|
|
||||||
|
|
@ -16,6 +16,8 @@ import System.Environment (getArgs)
|
|||||||
import System.Exit (exitFailure)
|
import System.Exit (exitFailure)
|
||||||
import System.IO (hPutStr, hPutStrLn, stdout, stderr, hSetEncoding, utf8)
|
import System.IO (hPutStr, hPutStrLn, stdout, stderr, hSetEncoding, utf8)
|
||||||
|
|
||||||
|
import Boot
|
||||||
|
|
||||||
----------------------------------------------------------------
|
----------------------------------------------------------------
|
||||||
|
|
||||||
ghcOptHelp :: String
|
ghcOptHelp :: String
|
||||||
@ -118,13 +120,7 @@ main = flip E.catches handlers $ do
|
|||||||
"lint" -> nArgs 1 withFile (lintSyntax opt) cmdArg1
|
"lint" -> nArgs 1 withFile (lintSyntax opt) cmdArg1
|
||||||
"root" -> rootInfo opt cradle
|
"root" -> rootInfo opt cradle
|
||||||
"doc" -> nArgs 1 $ packageDoc opt cradle cmdArg1
|
"doc" -> nArgs 1 $ packageDoc opt cradle cmdArg1
|
||||||
"boot" -> do
|
"boot" -> boot opt cradle
|
||||||
mods <- listModules opt cradle
|
|
||||||
langs <- listLanguages opt
|
|
||||||
flags <- listFlags opt
|
|
||||||
let opt' = addPackages opt
|
|
||||||
pre <- concat <$> mapM (browseModule opt' cradle) preBrowsedModules
|
|
||||||
return $ mods ++ langs ++ flags ++ pre
|
|
||||||
"help" -> return $ O.usageInfo usage argspec
|
"help" -> return $ O.usageInfo usage argspec
|
||||||
cmd -> E.throw (NoSuchCommand cmd)
|
cmd -> E.throw (NoSuchCommand cmd)
|
||||||
putStr res
|
putStr res
|
||||||
@ -156,32 +152,3 @@ main = flip E.catches handlers $ do
|
|||||||
xs !. idx
|
xs !. idx
|
||||||
| length xs <= idx = E.throw SafeList
|
| length xs <= idx = E.throw SafeList
|
||||||
| otherwise = xs !! idx
|
| otherwise = xs !! idx
|
||||||
|
|
||||||
----------------------------------------------------------------
|
|
||||||
|
|
||||||
preBrowsedModules :: [String]
|
|
||||||
preBrowsedModules = [
|
|
||||||
"Prelude"
|
|
||||||
, "Control.Applicative"
|
|
||||||
, "Control.Exception"
|
|
||||||
, "Control.Monad"
|
|
||||||
, "Data.ByteString"
|
|
||||||
, "Data.Char"
|
|
||||||
, "Data.List"
|
|
||||||
, "Data.Maybe"
|
|
||||||
, "System.Directory"
|
|
||||||
, "System.FilePath"
|
|
||||||
, "System.IO"
|
|
||||||
]
|
|
||||||
|
|
||||||
preBrowsePackages :: [String]
|
|
||||||
preBrowsePackages = [
|
|
||||||
"bytestring"
|
|
||||||
, "directory"
|
|
||||||
, "filepath"
|
|
||||||
]
|
|
||||||
|
|
||||||
addPackages :: Options -> Options
|
|
||||||
addPackages opt = opt { ghcOpts = pkgs ++ ghcOpts opt}
|
|
||||||
where
|
|
||||||
pkgs = map ("-package " ++) preBrowsePackages
|
|
||||||
|
Loading…
Reference in New Issue
Block a user