@@ -4,6 +4,7 @@ import Peura
44
55import qualified Data.Set as Set
66import qualified Distribution.Compat.CharParsing as P
7+ import qualified Distribution.ModuleName as C
78import qualified Distribution.Parsec as C
89import qualified Distribution.Types.BuildInfo as C
910import qualified Options.Applicative as O
@@ -31,7 +32,8 @@ data DynOpts = DynOpts
3132 , optTimeoutMsg :: String -- ^ timeout response
3233 , optGhciRtsopts :: [String ]
3334 , optSetup :: [String ]
34- , optExtraPkgs :: [PackageName ]
35+ , optExtraPkgs :: Set PackageName
36+ , optModules :: Set C. ModuleName
3537 , optCppIncludeDirs :: [FsPath ]
3638 , optProperties :: Properties
3739 , optPropVariables :: Set String
@@ -48,7 +50,8 @@ defaultDynOpts = DynOpts
4850 , optTimeoutMsg = " * Hangs forever *"
4951 , optGhciRtsopts = []
5052 , optSetup = []
51- , optExtraPkgs = []
53+ , optExtraPkgs = mempty
54+ , optModules = mempty
5255 , optCppIncludeDirs = []
5356 , optProperties = SkipProperties
5457 , optPropVariables = mempty
@@ -102,7 +105,7 @@ dynOptsFromBuildInfo tracer bi = do
102105 Left err -> do
103106 putWarning tracer WInvalidField $ name ++ " : " ++ err
104107 return id
105-
108+
106109 Right strs -> return $ \ dynOpts -> dynOpts
107110 { optPropVariables = Set. fromList strs <> optPropVariables dynOpts
108111 }
@@ -114,7 +117,7 @@ dynOptsFromBuildInfo tracer bi = do
114117 return id
115118
116119 Right pkgs -> return $ \ dynOpts -> dynOpts
117- { optExtraPkgs = optExtraPkgs dynOpts ++ pkgs
120+ { optExtraPkgs = optExtraPkgs dynOpts <> Set. fromList pkgs
118121 }
119122
120123
@@ -147,20 +150,24 @@ dynOptsP = pure combine
147150 <*> timeoutMsgP
148151 <*> monoidP rtsOptsP
149152 <*> listP (O. strOption (O. long " setup" <> O. metavar " EXPR" <> O. help " A setup expression" ))
150- <*> listP extraPkgP
153+ <*> setP extraPkgP
154+ <*> setP moduleNameP
151155 <*> listP cppDirP
152156 <*> propertiesP
153157 <*> monoidP propVariablesP
154158 <*> verbosityP
155159 where
160+ setP :: Ord a => O. Parser a -> O. Parser (Set a -> Set a )
161+ setP p = (\ xs ys -> Set. fromList xs <> ys) <$> many p
162+
156163 listP :: O. Parser a -> O. Parser ([a ] -> [a ])
157164 listP p = flip (++) <$> many p
158165
159166 monoidP :: Monoid a => O. Parser a -> O. Parser (a -> a )
160167 monoidP p = (\ xs ys -> mconcat (ys : xs)) <$> many p
161168
162- combine f1 f2 f3 f4 f5 f6 f7 f8 f9 fA fB fC fD (DynOpts x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD) =
163- DynOpts (f1 x1) (f2 x2) (f3 x3) (f4 x4) (f5 x5) (f6 x6) (f7 x7) (f8 x8) (f9 x9) (fA xA) (fB xB) (fC xC) (fD xD)
169+ combine f1 f2 f3 f4 f5 f6 f7 f8 f9 fA fB fC fD fE (DynOpts x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE ) =
170+ DynOpts (f1 x1) (f2 x2) (f3 x3) (f4 x4) (f5 x5) (f6 x6) (f7 x7) (f8 x8) (f9 x9) (fA xA) (fB xB) (fC xC) (fD xD) (fE xE)
164171
165172lastOpt :: [a ] -> a -> a
166173lastOpt xs initial = foldl' (\ _ x -> x) initial xs
@@ -200,6 +207,10 @@ extraPkgP :: O.Parser PackageName
200207extraPkgP = O. option (O. eitherReader C. eitherParsec) $
201208 O. long " extra-package" <> O. metavar " PKG" <> O. help " Extra packages to require (should exist in a plan)"
202209
210+ moduleNameP :: O. Parser C. ModuleName
211+ moduleNameP = O. option (O. eitherReader C. eitherParsec) $
212+ O. short ' m' <> O. long " module" <> O. metavar " MODULE" <> O. help " Which modules to check (all if empty)"
213+
203214rtsOptsP :: O. Parser [String ]
204215rtsOptsP = O. option (fmap words O. str) $
205216 O. long " ghci-rtsopts" <> O. metavar " OPTS" <> O. help " RTS options for GHCi process"
0 commit comments