Skip to content

Commit 1c078dc

Browse files
committed
Re commercialhaskell#5955 Minor reformatting and Haddock corrections
1 parent ebae0aa commit 1c078dc

File tree

3 files changed

+74
-37
lines changed

3 files changed

+74
-37
lines changed

src/Network/HTTP/StackClient.hs

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ module Network.HTTP.StackClient
3030
, applyDigestAuth
3131
, displayDigestAuthException
3232
, Request
33-
, RequestBody(RequestBodyBS, RequestBodyLBS)
33+
, RequestBody (RequestBodyBS, RequestBodyLBS)
3434
, Response (..)
3535
, HttpException (..)
3636
, HttpExceptionContent (..)
@@ -72,27 +72,30 @@ import qualified Data.Text as T
7272
import Data.Time.Clock
7373
( NominalDiffTime, diffUTCTime, getCurrentTime )
7474
import Network.HTTP.Client
75-
( HttpExceptionContent (..), Request, RequestBody (..), Response (..), parseRequest, getUri
76-
, path, checkResponse, parseUrlThrow
75+
( HttpException (..), HttpExceptionContent (..), Request
76+
, RequestBody (..), Response (..), checkResponse, getUri
77+
, parseRequest, parseUrlThrow, path
7778
)
78-
import Network.HTTP.Simple
79-
( setRequestCheckStatus, setRequestMethod, setRequestBody
80-
, setRequestHeader, addRequestHeader, HttpException (..)
81-
, getResponseBody, getResponseStatusCode, getResponseHeaders
82-
)
83-
import Network.HTTP.Types
84-
( hAccept, hContentLength, hContentMD5, methodPut, notFound404 )
85-
import Network.HTTP.Conduit ( requestHeaders )
79+
import Network.HTTP.Client.MultipartFormData
80+
( formDataBody, partBS, partFileRequestBody, partLBS )
8681
import Network.HTTP.Client.TLS
87-
( getGlobalManager, applyDigestAuth
88-
, displayDigestAuthException
82+
( applyDigestAuth, displayDigestAuthException
83+
, getGlobalManager
8984
)
85+
import Network.HTTP.Conduit ( requestHeaders )
9086
import Network.HTTP.Download
9187
hiding ( download, redownload, verifiedDownload )
9288
import qualified Network.HTTP.Download as Download
89+
import Network.HTTP.Simple
90+
( addRequestHeader, getResponseBody, getResponseHeaders
91+
, getResponseStatusCode, setRequestBody
92+
, setRequestCheckStatus, setRequestHeader, setRequestMethod
93+
)
9394
import qualified Network.HTTP.Simple
94-
import Network.HTTP.Client.MultipartFormData
95-
( formDataBody, partFileRequestBody, partBS, partLBS )
95+
import Network.HTTP.Types
96+
( hAccept, hContentLength, hContentMD5, methodPut
97+
, notFound404
98+
)
9699
import Path
97100
import Prelude ( until, (!!) )
98101
import RIO

src/Stack/Constants.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,18 +211,18 @@ inContainerEnvVar = stackProgNameUpper ++ "_IN_CONTAINER"
211211
inNixShellEnvVar :: String
212212
inNixShellEnvVar = map toUpper stackProgName ++ "_IN_NIX_SHELL"
213213

214-
-- | The comment to 'see
215-
-- https://downloads.haskell.org/~ghc/7.10.1/docs/html/libraries/ghc/src/Module.html#integerPackageKey'
214+
-- | The comment to \'see
215+
-- https://downloads.haskell.org/~ghc/7.10.1/docs/html/libraries/ghc/src/Module.html#integerPackageKey\'
216216
-- appears to be out of date.
217217
--
218-
-- See 'Note [About units]' and 'Wired-in units' at
218+
-- See \'Note [About units]\' and \'Wired-in units\' at
219219
-- https://gitlab.haskell.org/ghc/ghc/-/blob/master/compiler/GHC/Unit.hs.
220220
--
221-
-- The 'wired-in packages' appear to have been replaced by those that have (e.g)
221+
-- The \'wired-in packages\' appear to have been replaced by those that have (e.g)
222222
--
223223
-- > ghc-options: -this-unit-id ghc-prim
224224
--
225-
-- in their Cabal file because they are 'magic'.
225+
-- in their Cabal file because they are \'magic\'.
226226
wiredInPackages :: Set PackageName
227227
wiredInPackages = case mparsed of
228228
Just parsed -> Set.fromList parsed
@@ -239,7 +239,7 @@ wiredInPackages = case mparsed of
239239
, "base"
240240
-- A magic package
241241
, "rts"
242-
-- Said to be not a 'real' package
242+
-- Said to be not a \'real\' package
243243
, "template-haskell"
244244
-- A magic package
245245
, "dph-seq"

src/Stack/New.hs

Lines changed: 50 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,33 +15,38 @@ module Stack.New
1515
, templatesHelp
1616
) where
1717

18-
import Stack.Prelude
1918
import Control.Monad.Trans.Writer.Strict
2019
import Data.Aeson as A
2120
import qualified Data.Aeson.KeyMap as KeyMap
2221
import qualified Data.ByteString.Base64 as B64
23-
import Data.ByteString.Builder (lazyByteString)
22+
import Data.ByteString.Builder ( lazyByteString )
2423
import qualified Data.ByteString.Lazy as LB
2524
import Data.Conduit
2625
import qualified Data.List as L
2726
import qualified Data.Map.Strict as M
2827
import qualified Data.Set as S
2928
import qualified Data.Text as T
30-
import qualified Data.Text.Lazy as TL
3129
import qualified Data.Text.Encoding as T
30+
import qualified Data.Text.Lazy as TL
3231
import qualified Data.Text.Lazy.Encoding as TLE
3332
import Data.Time.Calendar
3433
import Data.Time.Clock
35-
import Network.HTTP.StackClient (VerifiedDownloadException (..), Response (..), HttpException (..), HttpExceptionContent (..),
36-
getResponseBody, httpLbs, mkDownloadRequest, notFound404, parseRequest, parseUrlThrow,
37-
setForceDownload, setGitHubHeaders, setRequestCheckStatus, verifiedDownloadWithProgress)
34+
import Network.HTTP.StackClient
35+
( HttpException (..), HttpExceptionContent (..)
36+
, Response (..), VerifiedDownloadException (..)
37+
, getResponseBody, httpLbs, mkDownloadRequest, notFound404
38+
, parseRequest, parseUrlThrow, setForceDownload
39+
, setGitHubHeaders, setRequestCheckStatus
40+
, verifiedDownloadWithProgress
41+
)
3842
import Path
3943
import Path.IO
44+
import RIO.Process
4045
import Stack.Constants
4146
import Stack.Constants.Config
47+
import Stack.Prelude
4248
import Stack.Types.Config
4349
import Stack.Types.TemplateName
44-
import RIO.Process
4550
import qualified Text.Mustache as Mustache
4651
import qualified Text.Mustache.Render as Mustache
4752
import Text.ProjectTemplate
@@ -306,7 +311,8 @@ loadTemplate
306311
loadTemplate name logIt = do
307312
templateDir <- view $ configL.to templatesDir
308313
case templatePath name of
309-
AbsPath absFile -> logIt LocalTemp >> loadLocalFile absFile eitherByteStringToText
314+
AbsPath absFile ->
315+
logIt LocalTemp >> loadLocalFile absFile eitherByteStringToText
310316
UrlPath s -> do
311317
let settings = asIsFromUrl s
312318
downloadFromUrl settings templateDir
@@ -328,7 +334,9 @@ loadTemplate name logIt = do
328334
downloadFromUrl settings templateDir
329335

330336
where
331-
loadLocalFile :: Path b File -> (ByteString -> Either String Text) -> RIO env Text
337+
loadLocalFile :: Path b File
338+
-> (ByteString -> Either String Text)
339+
-> RIO env Text
332340
loadLocalFile path extract = do
333341
logDebug ("Opening local template: \"" <> fromString (toFilePath path)
334342
<> "\"")
@@ -352,10 +360,15 @@ loadTemplate name logIt = do
352360
let url = tplDownloadUrl settings
353361
rel = fromMaybe backupUrlRelPath (parseRelFile url)
354362
downloadTemplate url (tplExtract settings) (templateDir </> rel)
355-
downloadTemplate :: String -> (ByteString -> Either String Text) -> Path Abs File -> RIO env Text
363+
downloadTemplate :: String
364+
-> (ByteString
365+
-> Either String Text)
366+
-> Path Abs File
367+
-> RIO env Text
356368
downloadTemplate url extract path = do
357369
req <- parseRequest url
358-
let dReq = setForceDownload True $ mkDownloadRequest (setRequestCheckStatus req)
370+
let dReq = setForceDownload True $
371+
mkDownloadRequest (setRequestCheckStatus req)
359372
logIt RemoteTemp
360373
catch
361374
(void $ do
@@ -364,7 +377,10 @@ loadTemplate name logIt = do
364377
(useCachedVersionOrThrow url path)
365378

366379
loadLocalFile path extract
367-
useCachedVersionOrThrow :: String -> Path Abs File -> VerifiedDownloadException -> RIO env ()
380+
useCachedVersionOrThrow :: String
381+
-> Path Abs File
382+
-> VerifiedDownloadException
383+
-> RIO env ()
368384
useCachedVersionOrThrow url path exception = do
369385
exists <- doesFileExist path
370386

@@ -396,7 +412,12 @@ settingsFromRepoTemplatePath :: RepoTemplatePath -> TemplateDownloadSettings
396412
settingsFromRepoTemplatePath (RepoTemplatePath GitHub user name) =
397413
-- T.concat ["https://raw.githubusercontent.com", "/", user, "/stack-templates/master/", name]
398414
TemplateDownloadSettings
399-
{ tplDownloadUrl = concat ["https://api.github.com/repos/", T.unpack user, "/stack-templates/contents/", T.unpack name]
415+
{ tplDownloadUrl = concat
416+
[ "https://api.github.com/repos/"
417+
, T.unpack user
418+
, "/stack-templates/contents/"
419+
, T.unpack name
420+
]
400421
, tplExtract = \bs -> do
401422
decodedJson <- eitherDecode (LB.fromStrict bs)
402423
case decodedJson of
@@ -409,9 +430,21 @@ settingsFromRepoTemplatePath (RepoTemplatePath GitHub user name) =
409430
}
410431

411432
settingsFromRepoTemplatePath (RepoTemplatePath GitLab user name) =
412-
asIsFromUrl $ concat ["https://gitlab.com", "/", T.unpack user, "/stack-templates/raw/master/", T.unpack name]
433+
asIsFromUrl $ concat
434+
[ "https://gitlab.com"
435+
, "/"
436+
, T.unpack user
437+
, "/stack-templates/raw/master/"
438+
, T.unpack name
439+
]
413440
settingsFromRepoTemplatePath (RepoTemplatePath Bitbucket user name) =
414-
asIsFromUrl $ concat ["https://bitbucket.org", "/", T.unpack user, "/stack-templates/raw/master/", T.unpack name]
441+
asIsFromUrl $ concat
442+
[ "https://bitbucket.org"
443+
, "/"
444+
, T.unpack user
445+
, "/stack-templates/raw/master/"
446+
, T.unpack name
447+
]
415448

416449
-- | Apply and unpack a template into a directory.
417450
applyTemplate
@@ -431,7 +464,8 @@ applyTemplate project template nonceParams dir templateText = do
431464
let context = M.unions [nonceParams, nameParams, configParams, yearParam]
432465
where
433466
nameAsVarId = T.replace "-" "_" $ T.pack $ packageNameString project
434-
nameAsModule = T.filter (/= ' ') $ T.toTitle $ T.replace "-" " " $ T.pack $ packageNameString project
467+
nameAsModule = T.filter (/= ' ') $ T.toTitle $ T.replace "-" " " $
468+
T.pack $ packageNameString project
435469
nameParams = M.fromList [ ("name", T.pack $ packageNameString project)
436470
, ("name-as-varid", nameAsVarId)
437471
, ("name-as-module", nameAsModule) ]

0 commit comments

Comments
 (0)