Skip to content

Commit 93f258e

Browse files
committed
Refactor: move GhciOpts to its own module
1 parent 16660c4 commit 93f258e

File tree

5 files changed

+43
-20
lines changed

5 files changed

+43
-20
lines changed

package.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ library:
319319
- Stack.Types.GhcOptions
320320
- Stack.Types.GhcPkgExe
321321
- Stack.Types.GhcPkgId
322+
- Stack.Types.GhciOpts
322323
- Stack.Types.GlobalOpts
323324
- Stack.Types.GlobalOptsMonoid
324325
- Stack.Types.HpcReportOpts

src/Stack/Ghci.hs

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ import Stack.Types.EnvConfig
8080
, shaPathForBytes
8181
)
8282
import Stack.Types.EnvSettings ( defaultEnvSettings )
83+
import Stack.Types.GhciOpts ( GhciOpts (..) )
8384
import Stack.Types.Installed ( InstallMap, InstalledMap )
8485
import Stack.Types.NamedComponent
8586
( NamedComponent (..), isCLib, isCSubLib, renderComponentTo
@@ -154,24 +155,6 @@ instance Pretty GhciPrettyException where
154155

155156
instance Exception GhciPrettyException
156157

157-
-- | Typre respresenting command line options for the @stack ghci@ and
158-
-- @stack repl@ commands.
159-
data GhciOpts = GhciOpts
160-
{ targets :: ![Text]
161-
, args :: ![String]
162-
, ghcOptions :: ![String]
163-
, flags :: !(Map ApplyCLIFlag (Map FlagName Bool))
164-
, ghcCommand :: !(Maybe FilePath)
165-
, noLoadModules :: !Bool
166-
, additionalPackages :: ![String]
167-
, mainIs :: !(Maybe Text)
168-
, loadLocalDeps :: !Bool
169-
, hidePackages :: !(Maybe Bool)
170-
, noBuild :: !Bool
171-
, onlyMain :: !Bool
172-
}
173-
deriving Show
174-
175158
-- | Type representing information required to load a package or its components.
176159
--
177160
-- NOTE: GhciPkgInfo has paths as list instead of a Set to preserve files order

src/Stack/Options/GhciParser.hs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33

44
{-|
55
Module : Stack.Options.GhciParser
6+
Description : Parse arguments for Stack's @ghci@ and @repl@ commands.
67
License : BSD-3-Clause
8+
9+
Function to parse arguments for Stack's @ghci@ and @repl@ commands.
710
-}
811

912
module Stack.Options.GhciParser
@@ -19,13 +22,13 @@ import Options.Applicative.Builder.Extra
1922
( boolFlags, boolFlagsNoDefault, fileExtCompleter
2023
, textArgument, textOption
2124
)
22-
import Stack.Ghci ( GhciOpts (..) )
2325
import Stack.Options.Completion ( ghcOptsCompleter, targetCompleter )
2426
import Stack.Options.FlagsParser ( flagsParser )
2527
import Stack.Options.PackagesParser ( packagesParser )
2628
import Stack.Prelude
29+
import Stack.Types.GhciOpts ( GhciOpts (..) )
2730

28-
-- | Parser for GHCI options
31+
-- | Parse command line arguments for Stack's @ghci@ and @repl@ commands.
2932
ghciOptsParser :: Parser GhciOpts
3033
ghciOptsParser = GhciOpts
3134
<$> many (textArgument

src/Stack/Types/GhciOpts.hs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{-# LANGUAGE NoImplicitPrelude #-}
2+
{-# LANGUAGE NoFieldSelectors #-}
3+
4+
{-|
5+
Module : Stack.Types.GhciOpts
6+
Description : Types related to Stack's @ghci@ and @repl@ commands.
7+
License : BSD-3-Clause
8+
9+
Types related to Stack's @ghci@ and @repl@ commands.
10+
-}
11+
12+
module Stack.Types.GhciOpts
13+
( GhciOpts (..)
14+
) where
15+
16+
import Stack.Prelude
17+
import Stack.Types.BuildOptsCLI ( ApplyCLIFlag (..) )
18+
19+
-- | Type respresenting command line options for Stack's @ghci@ and @repl@
20+
-- commands.
21+
data GhciOpts = GhciOpts
22+
{ targets :: ![Text]
23+
, args :: ![String]
24+
, ghcOptions :: ![String]
25+
, flags :: !(Map ApplyCLIFlag (Map FlagName Bool))
26+
, ghcCommand :: !(Maybe FilePath)
27+
, noLoadModules :: !Bool
28+
, additionalPackages :: ![String]
29+
, mainIs :: !(Maybe Text)
30+
, loadLocalDeps :: !Bool
31+
, hidePackages :: !(Maybe Bool)
32+
, noBuild :: !Bool
33+
, onlyMain :: !Bool
34+
}
35+
deriving Show

stack.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ library
355355
Stack.Types.GhcOptions
356356
Stack.Types.GhcPkgExe
357357
Stack.Types.GhcPkgId
358+
Stack.Types.GhciOpts
358359
Stack.Types.GlobalOpts
359360
Stack.Types.GlobalOptsMonoid
360361
Stack.Types.HpcReportOpts

0 commit comments

Comments
 (0)