Skip to content

Commit bb40e56

Browse files
authored
Merge pull request #5972 from commercialhaskell/imports
Add explicit import lists
2 parents ca4bc6c + 8d668c6 commit bb40e56

File tree

4 files changed

+297
-290
lines changed

4 files changed

+297
-290
lines changed

src/Options/Applicative/Args.hs

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,40 @@
44
-- | Accepting arguments to be passed through to a sub-process.
55

66
module Options.Applicative.Args
7-
(argsArgument
8-
,argsOption
9-
,cmdOption)
10-
where
7+
( argsArgument
8+
, argsOption
9+
, cmdOption
10+
) where
1111

12-
import Data.Attoparsec.Args
12+
import Data.Attoparsec.Args ( EscapingMode (..), parseArgsFromString )
1313
import qualified Options.Applicative as O
1414
import Stack.Prelude
1515

16-
-- | An argument which accepts a list of arguments e.g. @--ghc-options="-X P.hs \"this\""@.
16+
-- | An argument which accepts a list of arguments
17+
-- e.g. @--ghc-options="-X P.hs \"this\""@.
1718
argsArgument :: O.Mod O.ArgumentFields [String] -> O.Parser [String]
1819
argsArgument =
19-
O.argument
20-
(do s <- O.str
21-
either O.readerError pure (parseArgsFromString Escaping s))
20+
O.argument
21+
(do s <- O.str
22+
either O.readerError pure (parseArgsFromString Escaping s))
2223

23-
-- | An option which accepts a list of arguments e.g. @--ghc-options="-X P.hs \"this\""@.
24+
-- | An option which accepts a list of arguments
25+
-- e.g. @--ghc-options="-X P.hs \"this\""@.
2426
argsOption :: O.Mod O.OptionFields [String] -> O.Parser [String]
2527
argsOption =
26-
O.option
27-
(do s <- O.str
28-
either O.readerError pure (parseArgsFromString Escaping s))
28+
O.option
29+
(do s <- O.str
30+
either O.readerError pure (parseArgsFromString Escaping s))
2931

30-
-- | An option which accepts a command and a list of arguments e.g. @--exec "echo hello world"@
31-
cmdOption :: O.Mod O.OptionFields (String, [String]) -> O.Parser (String, [String])
32+
-- | An option which accepts a command and a list of arguments
33+
-- e.g. @--exec "echo hello world"@
34+
cmdOption ::
35+
O.Mod O.OptionFields (String, [String])
36+
-> O.Parser (String, [String])
3237
cmdOption =
33-
O.option
34-
(do s <- O.str
35-
xs <- either O.readerError pure (parseArgsFromString Escaping s)
36-
case xs of
37-
[] -> O.readerError "Must provide a command"
38-
x:xs' -> pure (x, xs'))
38+
O.option
39+
(do s <- O.str
40+
xs <- either O.readerError pure (parseArgsFromString Escaping s)
41+
case xs of
42+
[] -> O.readerError "Must provide a command"
43+
x:xs' -> pure (x, xs'))

src/Stack/Config/Nix.hs

Lines changed: 41 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@
55

66
-- | Nix configuration
77
module Stack.Config.Nix
8-
(nixOptsFromMonoid
9-
,nixCompiler
10-
,nixCompilerVersion
11-
) where
8+
( nixCompiler
9+
, nixCompilerVersion
10+
, nixOptsFromMonoid
11+
) where
1212

1313
import Control.Monad.Extra ( ifM )
1414
import qualified Data.Text as T
1515
import qualified Data.Text.IO as TIO
1616
import Distribution.System ( OS (..) )
17-
import Stack.Constants
17+
import Stack.Constants ( osIsWindows )
1818
import Stack.Prelude
19-
import Stack.Types.Config
20-
import Stack.Types.Nix
19+
import Stack.Types.Config ( HasRunner )
20+
import Stack.Types.Nix ( NixOpts (..), NixOptsMonoid (..) )
2121
import System.Directory ( doesFileExist )
2222

2323
-- | Type representing exceptions thrown by functions exported by the
@@ -42,37 +42,40 @@ instance Exception ConfigNixException where
4242
++ "Only GHC is supported by 'stack --nix'."
4343

4444
-- | Interprets NixOptsMonoid options.
45-
nixOptsFromMonoid
46-
:: HasRunner env
47-
=> NixOptsMonoid
48-
-> OS
49-
-> RIO env NixOpts
45+
nixOptsFromMonoid ::
46+
HasRunner env
47+
=> NixOptsMonoid
48+
-> OS
49+
-> RIO env NixOpts
5050
nixOptsFromMonoid NixOptsMonoid{..} os = do
51-
let defaultPure = case os of
52-
OSX -> False
53-
_ -> True
54-
nixPureShell = fromFirst defaultPure nixMonoidPureShell
55-
nixPackages = fromFirst [] nixMonoidPackages
56-
nixInitFile = getFirst nixMonoidInitFile
57-
nixShellOptions = fromFirst [] nixMonoidShellOptions
58-
++ prefixAll (T.pack "-I") (fromFirst [] nixMonoidPath)
59-
nixAddGCRoots = fromFirstFalse nixMonoidAddGCRoots
51+
let defaultPure = case os of
52+
OSX -> False
53+
_ -> True
54+
nixPureShell = fromFirst defaultPure nixMonoidPureShell
55+
nixPackages = fromFirst [] nixMonoidPackages
56+
nixInitFile = getFirst nixMonoidInitFile
57+
nixShellOptions = fromFirst [] nixMonoidShellOptions
58+
++ prefixAll (T.pack "-I") (fromFirst [] nixMonoidPath)
59+
nixAddGCRoots = fromFirstFalse nixMonoidAddGCRoots
6060

61-
-- Enable Nix-mode by default on NixOS, unless Docker-mode was specified
62-
osIsNixOS <- isNixOS
63-
let nixEnable0 = fromFirst osIsNixOS nixMonoidEnable
61+
-- Enable Nix-mode by default on NixOS, unless Docker-mode was specified
62+
osIsNixOS <- isNixOS
63+
let nixEnable0 = fromFirst osIsNixOS nixMonoidEnable
6464

65-
nixEnable <- case () of _
66-
| nixEnable0 && osIsWindows -> do
67-
logInfo "Note: Disabling nix integration, since this is being run in Windows"
68-
pure False
69-
| otherwise -> pure nixEnable0
65+
nixEnable <- case () of
66+
_
67+
| nixEnable0 && osIsWindows -> do
68+
logInfo
69+
"Note: Disabling nix integration, since this is being run in Windows"
70+
pure False
71+
| otherwise -> pure nixEnable0
7072

71-
when (not (null nixPackages) && isJust nixInitFile) $
72-
throwIO NixCannotUseShellFileAndPackagesException
73-
pure NixOpts{..}
74-
where prefixAll p (x:xs) = p : x : prefixAll p xs
75-
prefixAll _ _ = []
73+
when (not (null nixPackages) && isJust nixInitFile) $
74+
throwIO NixCannotUseShellFileAndPackagesException
75+
pure NixOpts{..}
76+
where
77+
prefixAll p (x:xs) = p : x : prefixAll p xs
78+
prefixAll _ _ = []
7679

7780
nixCompiler :: WantedCompiler -> Either ConfigNixException T.Text
7881
nixCompiler compilerVersion =
@@ -112,7 +115,7 @@ nixCompilerVersion compilerVersion =
112115

113116
isNixOS :: MonadIO m => m Bool
114117
isNixOS = liftIO $ do
115-
let fp = "/etc/os-release"
116-
ifM (doesFileExist fp)
117-
(T.isInfixOf "ID=nixos" <$> TIO.readFile fp)
118-
(pure False)
118+
let fp = "/etc/os-release"
119+
ifM (doesFileExist fp)
120+
(T.isInfixOf "ID=nixos" <$> TIO.readFile fp)
121+
(pure False)

0 commit comments

Comments
 (0)