Skip to content

Commit

Permalink
Merge pull request #6684 from commercialhaskell/reformat
Browse files Browse the repository at this point in the history
Minor reformatting of signatures, for consistency
  • Loading branch information
mpilgrem authored Feb 9, 2025
2 parents 33485f2 + 5c48a31 commit 267430a
Show file tree
Hide file tree
Showing 26 changed files with 401 additions and 306 deletions.
44 changes: 22 additions & 22 deletions .stan.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,24 @@
# Infinite: base/isSuffixOf
# Usage of the 'isSuffixOf' function that hangs on infinite lists
[[ignore]]
id = "OBS-STAN-0102-luLR/n-525:30"
id = "OBS-STAN-0102-luLR/n-527:30"
# ✦ Category: #Infinite #List
# ✦ File: src\Stack\New.hs
#
# 524
# 525 ┃ let isPkgSpec f = ".cabal" `L.isSuffixOf` f || "package.yaml" `L.isSuffixOf` f
# 526 ┃ ^^^^^^^^^^^^^^
# 526
# 527 ┃ let isPkgSpec f = ".cabal" `L.isSuffixOf` f || "package.yaml" `L.isSuffixOf` f
# 528 ┃ ^^^^^^^^^^^^^^

# Infinite: base/isSuffixOf
# Usage of the 'isSuffixOf' function that hangs on infinite lists
[[ignore]]
id = "OBS-STAN-0102-luLR/n-525:65"
id = "OBS-STAN-0102-luLR/n-527:65"
# ✦ Category: #Infinite #List
# ✦ File: src\Stack\New.hs
#
# 524
# 525 ┃ let isPkgSpec f = ".cabal" `L.isSuffixOf` f || "package.yaml" `L.isSuffixOf` f
# 526 ┃ ^^^^^^^^^^^^^^
# 526
# 527 ┃ let isPkgSpec f = ".cabal" `L.isSuffixOf` f || "package.yaml" `L.isSuffixOf` f
# 528 ┃ ^^^^^^^^^^^^^^

# Infinite: base/length
# Usage of the 'length' function that hangs on infinite lists
Expand All @@ -72,25 +72,25 @@

# Anti-pattern: Data.ByteString.Char8.pack
[[ignore]]
id = "OBS-STAN-0203-erw24B-1039:3"
id = "OBS-STAN-0203-erw24B-1053:3"
# ✦ Description: Usage of 'pack' function that doesn't handle Unicode characters
# ✦ Category: #AntiPattern
# ✦ File: src\Stack\Build\ExecuteEnv.hs
#
# 1038
# 1039 ┃ S8.pack . formatTime defaultTimeLocale "%Y-%m-%dT%H:%M:%S%6Q"
# 1040 ┃ ^^^^^^^
# 1052
# 1053 ┃ S8.pack . formatTime defaultTimeLocale "%Y-%m-%dT%H:%M:%S%6Q"
# 1054 ┃ ^^^^^^^

# Anti-pattern: Data.ByteString.Char8.pack
[[ignore]]
id = "OBS-STAN-0203-tuE+RG-236:24"
id = "OBS-STAN-0203-tuE+RG-242:24"
# ✦ Description: Usage of 'pack' function that doesn't handle Unicode characters
# ✦ Category: #AntiPattern
# ✦ File: src\Stack\Build\ExecutePackage.hs
#
# 235
# 236 ┃ newConfigFileRoot <- S8.pack . toFilePath <$> view configFileRootL
# 237 ┃ ^^^^^^^
# 241
# 242 ┃ newConfigFileRoot <- S8.pack . toFilePath <$> view configFileRootL
# 243 ┃ ^^^^^^^

# Anti-pattern: Data.ByteString.Char8.pack
[[ignore]]
Expand Down Expand Up @@ -177,16 +177,16 @@

# Anti-pattern: unsafe functions
[[ignore]]
id = "OBS-STAN-0212-5rtOmw-460:33"
id = "OBS-STAN-0212-5rtOmw-461:33"
# ✦ Description: Usage of unsafe functions breaks referential transparency
# ✦ Category: #Unsafe #AntiPattern
# ✦ File: src\Stack\Constants.hs
#
# 459
# 460 ┃ setupGhciShimCode = byteString $(do
# 461 ┃ path <- makeRelativeToProject "src/setup-shim/StackSetupShim.hs"
# 462 ┃ embedFile path)
# 463
# 460
# 461 ┃ setupGhciShimCode = byteString $(do
# 462 ┃ path <- makeRelativeToProject "src/setup-shim/StackSetupShim.hs"
# 463 ┃ embedFile path)
# 464

# Anti-pattern: unsafe functions
[[ignore]]
Expand Down
15 changes: 8 additions & 7 deletions src/GHC/Utils/GhcPkg/Main/Compat.hs
Original file line number Diff line number Diff line change
Expand Up @@ -554,13 +554,14 @@ unregisterPackages globalDb pkgargs pkgDb = do
where
-- Update a list of 'packages by package database' for a package. Assumes that
-- a package to be unregistered is in no more than one database.
getPkgsByPkgDBs :: [(PackageDB GhcPkg.DbReadWrite, [UnitId])]
-- ^ List of considered 'packages by package database'
-> [(PackageDB GhcPkg.DbReadWrite, [UnitId])]
-- ^ List of to be considered 'packages by package database'
-> PackageArg
-- Package to update
-> RIO env [(PackageDB GhcPkg.DbReadWrite, [UnitId])]
getPkgsByPkgDBs ::
[(PackageDB GhcPkg.DbReadWrite, [UnitId])]
-- ^ List of considered 'packages by package database'
-> [(PackageDB GhcPkg.DbReadWrite, [UnitId])]
-- ^ List of to be considered 'packages by package database'
-> PackageArg
-- Package to update
-> RIO env [(PackageDB GhcPkg.DbReadWrite, [UnitId])]
-- No more 'packages by package database' to consider? We need to try to get
-- another package database.
getPkgsByPkgDBs pkgsByPkgDBs [] pkgarg =
Expand Down
21 changes: 13 additions & 8 deletions src/Network/HTTP/StackClient.hs
Original file line number Diff line number Diff line change
Expand Up @@ -153,19 +153,24 @@ setGitHubHeaders = setRequestHeader "Accept" ["application/vnd.github.v3+json"]
-- appropriate destination.
--
-- Throws an exception if things go wrong
download :: HasTerm env
=> Request
-> Path Abs File -- ^ destination
-> RIO env Bool -- ^ Was a downloaded performed (True) or did the file already exist (False)?
download ::
HasTerm env
=> Request
-> Path Abs File
-- ^ destination
-> RIO env Bool
-- ^ Was a downloaded performed (True) or did the file already exist
-- (False)?
download req = Download.download (setUserAgent req)

-- | Same as 'download', but will download a file a second time if it is already present.
--
-- Returns 'True' if the file was downloaded, 'False' otherwise
redownload :: HasTerm env
=> Request
-> Path Abs File -- ^ destination
-> RIO env Bool
redownload ::
HasTerm env
=> Request
-> Path Abs File -- ^ destination
-> RIO env Bool
redownload req = Download.redownload (setUserAgent req)

-- | Copied and extended version of Network.HTTP.Download.download.
Expand Down
62 changes: 33 additions & 29 deletions src/Path/Find.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,36 @@ import System.PosixCompat.Files
( getSymbolicLinkStatus, isSymbolicLink )

-- | Find the location of a file matching the given predicate.
findFileUp :: (MonadIO m, MonadThrow m)
=> Path Abs Dir -- ^ Start here.
-> (Path Abs File -> Bool) -- ^ Predicate to match the file.
-> Maybe (Path Abs Dir) -- ^ Do not ascend above this directory.
-> m (Maybe (Path Abs File)) -- ^ Absolute file path.
findFileUp ::
(MonadIO m, MonadThrow m)
=> Path Abs Dir -- ^ Start here.
-> (Path Abs File -> Bool) -- ^ Predicate to match the file.
-> Maybe (Path Abs Dir) -- ^ Do not ascend above this directory.
-> m (Maybe (Path Abs File)) -- ^ Absolute file path.
findFileUp = findPathUp snd

-- | Find the location of a directory matching the given predicate.
findDirUp :: (MonadIO m,MonadThrow m)
=> Path Abs Dir -- ^ Start here.
-> (Path Abs Dir -> Bool) -- ^ Predicate to match the directory.
-> Maybe (Path Abs Dir) -- ^ Do not ascend above this directory.
-> m (Maybe (Path Abs Dir)) -- ^ Absolute directory path.
findDirUp ::
(MonadIO m,MonadThrow m)
=> Path Abs Dir -- ^ Start here.
-> (Path Abs Dir -> Bool) -- ^ Predicate to match the directory.
-> Maybe (Path Abs Dir) -- ^ Do not ascend above this directory.
-> m (Maybe (Path Abs Dir)) -- ^ Absolute directory path.
findDirUp = findPathUp fst

-- | Find the location of a path matching the given predicate.
findPathUp :: (MonadIO m,MonadThrow m)
=> (([Path Abs Dir],[Path Abs File]) -> [Path Abs t])
-- ^ Choose path type from pair.
-> Path Abs Dir
-- ^ Start here.
-> (Path Abs t -> Bool)
-- ^ Predicate to match the path.
-> Maybe (Path Abs Dir)
-- ^ Do not ascend above this directory.
-> m (Maybe (Path Abs t))
-- ^ Absolute path.
findPathUp ::
(MonadIO m,MonadThrow m)
=> (([Path Abs Dir],[Path Abs File]) -> [Path Abs t])
-- ^ Choose path type from pair.
-> Path Abs Dir
-- ^ Start here.
-> (Path Abs t -> Bool)
-- ^ Predicate to match the path.
-> Maybe (Path Abs Dir)
-- ^ Do not ascend above this directory.
-> m (Maybe (Path Abs t))
-- ^ Absolute path.
findPathUp pathType dir p upperBound = do
entries <- listDir dir
case L.find p (pathType entries) of
Expand All @@ -61,14 +64,15 @@ findPathUp pathType dir p upperBound = do
--
-- TODO: write one of these that traverses symbolic links but
-- efficiently ignores loops.
findFiles :: Path Abs Dir
-- ^ Root directory to begin with.
-> (Path Abs File -> Bool)
-- ^ Predicate to match files.
-> (Path Abs Dir -> Bool)
-- ^ Predicate for which directories to traverse.
-> IO [Path Abs File]
-- ^ List of matching files.
findFiles ::
Path Abs Dir
-- ^ Root directory to begin with.
-> (Path Abs File -> Bool)
-- ^ Predicate to match files.
-> (Path Abs Dir -> Bool)
-- ^ Predicate for which directories to traverse.
-> IO [Path Abs File]
-- ^ List of matching files.
findFiles dir p traversep = do
(dirs,files) <- catchJust (\ e -> if isPermissionError e
then Just ()
Expand Down
Loading

0 comments on commit 267430a

Please sign in to comment.