Skip to content

Commit e50fa0f

Browse files
committed
Move types relating to command line options into their own modules
Also adds some missing Haddock documentation.
1 parent 31587d1 commit e50fa0f

File tree

11 files changed

+99
-54
lines changed

11 files changed

+99
-54
lines changed

package.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,13 +335,15 @@ library:
335335
- Stack.Types.PvpBounds
336336
- Stack.Types.Runner
337337
- Stack.Types.SCM
338+
- Stack.Types.SDistOpts
338339
- Stack.Types.SetupInfo
339340
- Stack.Types.Snapshot
340341
- Stack.Types.SourceMap
341342
- Stack.Types.StackYamlLoc
342343
- Stack.Types.Storage
343344
- Stack.Types.TemplateName
344345
- Stack.Types.UnusedFlags
346+
- Stack.Types.UpgradeOpts
345347
- Stack.Types.UploadOpts
346348
- Stack.Types.Version
347349
- Stack.Types.VersionedDownloadInfo

src/Stack/Build.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,11 @@ build msetLocalFiles = do
233233
sourceMap.targets.targets
234234
plan
235235

236+
-- | Build one or more local targets.
236237
buildLocalTargets ::
237238
HasEnvConfig env
238239
=> NonEmpty Text
240+
-- ^ Local targets to build.
239241
-> RIO env (Either SomeException ())
240242
buildLocalTargets targets =
241243
tryAny $ withNewLocalBuildTargets (NE.toList targets) $ build Nothing
@@ -377,6 +379,7 @@ warnAboutSplitObjs bopts | bopts.splitObjs =
377379
]
378380
warnAboutSplitObjs _ = pure ()
379381

382+
-- | Text warning about the experimental nature of Stack's @--split-objs@ flag.
380383
splitObjsWarning :: String
381384
splitObjsWarning =
382385
"Note that this feature is EXPERIMENTAL, and its behavior may be changed and \

src/Stack/Options/SDistParser.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import Options.Applicative
1818
)
1919
import Options.Applicative.Builder.Extra ( boolFlags, dirCompleter )
2020
import Stack.Prelude
21-
import Stack.SDist ( SDistOpts (..) )
21+
import Stack.Types.SDistOpts ( SDistOpts (..) )
2222
import Stack.Options.PvpBoundsParser ( pvpBoundsParser )
2323

2424
-- | Parse command line arguments for Stack's @sdist@ command.

src/Stack/Options/UpgradeParser.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Module : Stack.Options.UpgradeParser
55
Description : Parse arguments for Stack's @upgrade@ command.
66
License : BSD-3-Clause
77
8-
Functions to parse command line arguments for Stack's @upgrade@ command.
8+
Function to parse command line arguments for Stack's @upgrade@ command.
99
-}
1010

1111
module Stack.Options.UpgradeParser
@@ -18,7 +18,7 @@ import Options.Applicative
1818
)
1919
import Options.Applicative.Builder.Extra ( boolFlags )
2020
import Stack.Prelude
21-
import Stack.Upgrade
21+
import Stack.Types.UpgradeOpts
2222
( BinaryOpts (..), SourceOpts (..), UpgradeOpts (..) )
2323

2424
-- | Parse command line arguments for Stack's @upgrade@ command.

src/Stack/SDist.hs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ import Stack.Types.Package
9292
import Stack.Types.Platform ( HasPlatform (..) )
9393
import Stack.Types.PvpBounds ( PvpBounds (..), PvpBoundsType (..) )
9494
import Stack.Types.Runner ( HasRunner, Runner )
95+
import Stack.Types.SDistOpts ( SDistOpts (..) )
9596
import Stack.Types.SourceMap
9697
( CommonPackage (..), ProjectPackage (..), SMWanted (..)
9798
, SourceMap (..), ppRoot
@@ -137,20 +138,6 @@ instance Pretty SDistPrettyException where
137138

138139
instance Exception SDistPrettyException
139140

140-
-- | Type representing command line options for @stack sdist@ command.
141-
data SDistOpts = SDistOpts
142-
{ dirsToWorkWith :: [String]
143-
-- ^ Directories to package
144-
, pvpBounds :: Maybe PvpBounds
145-
-- ^ PVP Bounds overrides
146-
, ignoreCheck :: Bool
147-
-- ^ Whether to ignore check of the package for common errors
148-
, buildTarball :: Bool
149-
-- ^ Whether to build the tarball
150-
, tarPath :: Maybe FilePath
151-
-- ^ Where to copy the tarball
152-
}
153-
154141
-- | Function underlying the @stack sdist@ command.
155142
sdistCmd :: SDistOpts -> RIO Runner ()
156143
sdistCmd sdistOpts =

src/Stack/Types/Build.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,13 @@ instance NFData (PrecompiledCache Abs)
258258

259259
instance NFData (PrecompiledCache Rel)
260260

261+
-- | Type representing treatments of GHC's informational messages during
262+
-- compilation when it evaluates Template Haskell code.
261263
data ExcludeTHLoading
262264
= ExcludeTHLoading
265+
-- ^ Suppress the messages.
263266
| KeepTHLoading
267+
-- ^ Do not suppress the messages.
264268

265269
data ConvertPathsToAbsolute
266270
= ConvertPathsToAbsolute

src/Stack/Types/SDistOpts.hs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{-# LANGUAGE NoImplicitPrelude #-}
2+
{-# LANGUAGE NoFieldSelectors #-}
3+
4+
{-|
5+
Module : Stack.Types.SDistOpts
6+
Description : Types related to Stack's @sdist@ command.
7+
License : BSD-3-Clause
8+
9+
Types related to Stack's @sdist@ command.
10+
-}
11+
12+
module Stack.Types.SDistOpts
13+
( SDistOpts (..)
14+
) where
15+
16+
import Stack.Prelude
17+
import Stack.Types.PvpBounds ( PvpBounds )
18+
19+
-- | Type representing command line options for @stack sdist@ command.
20+
data SDistOpts = SDistOpts
21+
{ dirsToWorkWith :: [String]
22+
-- ^ Directories to package
23+
, pvpBounds :: Maybe PvpBounds
24+
-- ^ PVP Bounds overrides
25+
, ignoreCheck :: Bool
26+
-- ^ Whether to ignore check of the package for common errors
27+
, buildTarball :: Bool
28+
-- ^ Whether to build the tarball
29+
, tarPath :: Maybe FilePath
30+
-- ^ Where to copy the tarball
31+
}

src/Stack/Types/UpgradeOpts.hs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{-# LANGUAGE NoImplicitPrelude #-}
2+
{-# LANGUAGE NoFieldSelectors #-}
3+
4+
{-|
5+
Module : Stack.Types.UpgradeOpts
6+
Description : Types for command line options for Stack's @upgrade@ command.
7+
License : BSD-3-Clause
8+
9+
Types for command line options for Stack's @upgrade@ command.
10+
-}
11+
12+
module Stack.Types.UpgradeOpts
13+
( UpgradeOpts (..)
14+
, BinaryOpts (..)
15+
, SourceOpts (..)
16+
) where
17+
18+
import Stack.Prelude
19+
20+
-- | Type representing command line options for the @stack upgrade@ command.
21+
data UpgradeOpts = UpgradeOpts
22+
{ binary :: !(Maybe BinaryOpts)
23+
, source :: !(Maybe SourceOpts)
24+
}
25+
deriving Show
26+
27+
-- | Type representing options for upgrading Stack with a binary executable
28+
-- file.
29+
data BinaryOpts = BinaryOpts
30+
{ platform :: !(Maybe String)
31+
, force :: !Bool
32+
-- ^ Force a download, even if the downloaded version is older than what we
33+
-- are.
34+
, onlyLocalBin :: !Bool
35+
-- ^ Only download to Stack's local binary directory.
36+
, version :: !(Maybe String)
37+
-- ^ Specific version to download
38+
, gitHubOrg :: !(Maybe String)
39+
, gitHubRepo :: !(Maybe String)
40+
}
41+
deriving Show
42+
43+
-- | Type representing options for upgrading Stack from source code.
44+
newtype SourceOpts
45+
= SourceOpts (Maybe (String, String)) -- repo and branch
46+
deriving Show

src/Stack/Types/UploadOpts.hs

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

44
{-|
55
Module : Stack.Types.UploadOpts
6-
Description : Types for command line options for the @stack upload@ command.
6+
Description : Types for command line options for Stack's @upload@ command.
77
License : BSD-3-Clause
88
9-
Types for command line options for the @stack upload@ command.
9+
Types for command line options for Stack's @upload@ command.
1010
-}
1111

1212
module Stack.Types.UploadOpts

src/Stack/Upgrade.hs

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,14 @@
55

66
{-|
77
Module : Stack.Upgrade
8-
Description : Types and functions related to Stack's @upgrade@ command.
8+
Description : Function related to Stack's @upgrade@ command.
99
License : BSD-3-Clause
1010
11-
Types and functions related to Stack's @upgrade@ command.
11+
Function related to Stack's @upgrade@ command.
1212
-}
1313

1414
module Stack.Upgrade
15-
( UpgradeOpts (..)
16-
, BinaryOpts (..)
17-
, SourceOpts (..)
18-
, upgradeCmd
19-
, upgrade
15+
( upgradeCmd
2016
) where
2117

2218
import qualified Data.Text as T
@@ -41,6 +37,8 @@ import Stack.Types.Config ( Config (..), HasConfig (..), buildOptsL )
4137
import Stack.Types.GlobalOpts ( GlobalOpts (..) )
4238
import Stack.Types.Runner ( Runner, globalOptsL )
4339
import Stack.Types.StackYamlLoc ( StackYamlLoc (..) )
40+
import Stack.Types.UpgradeOpts
41+
( BinaryOpts (..), SourceOpts (..), UpgradeOpts (..) )
4442
import System.Process ( rawSystem, readProcess )
4543

4644
-- | Type representing \'pretty\' exceptions thrown by functions in the
@@ -93,34 +91,6 @@ instance Pretty UpgradePrettyException where
9391

9492
instance Exception UpgradePrettyException
9593

96-
-- | Type representing options for upgrading Stack with a binary executable
97-
-- file.
98-
data BinaryOpts = BinaryOpts
99-
{ platform :: !(Maybe String)
100-
, force :: !Bool
101-
-- ^ Force a download, even if the downloaded version is older than what we
102-
-- are.
103-
, onlyLocalBin :: !Bool
104-
-- ^ Only download to Stack's local binary directory.
105-
, version :: !(Maybe String)
106-
-- ^ Specific version to download
107-
, gitHubOrg :: !(Maybe String)
108-
, gitHubRepo :: !(Maybe String)
109-
}
110-
deriving Show
111-
112-
-- | Type representing options for upgrading Stack from source code.
113-
newtype SourceOpts
114-
= SourceOpts (Maybe (String, String)) -- repo and branch
115-
deriving Show
116-
117-
-- | Type representing command line options for the @stack upgrade@ command.
118-
data UpgradeOpts = UpgradeOpts
119-
{ binary :: !(Maybe BinaryOpts)
120-
, source :: !(Maybe SourceOpts)
121-
}
122-
deriving Show
123-
12494
-- | Function underlying the @stack upgrade@ command.
12595
upgradeCmd :: UpgradeOpts -> RIO Runner ()
12696
upgradeCmd upgradeOpts = do

0 commit comments

Comments
 (0)