Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Follow HLint suggestion: use fewer imports #10719

Merged
merged 3 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions .hlint.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Warnings currently triggered by your code
- ignore: {name: "Avoid NonEmpty.unzip"} # 1 hint
- ignore: {name: "Avoid lambda"} # 47 hints
- ignore: {name: "Avoid lambda using `infix`"} # 22 hints
- ignore: {name: "Avoid lambda using `infix`"} # 23 hints
- ignore: {name: "Eta reduce"} # 124 hints
- ignore: {name: "Evaluate"} # 10 hints
- ignore: {name: "Functor law"} # 10 hints
Expand All @@ -16,11 +16,11 @@
- ignore: {name: "Monoid law, right identity"} # 3 hints
- ignore: {name: "Move filter"} # 4 hints
- ignore: {name: "Move guards forward"} # 4 hints
- ignore: {name: "Redundant $"} # 179 hints
- ignore: {name: "Redundant $"} # 178 hints
- ignore: {name: "Redundant $!"} # 1 hint
- ignore: {name: "Redundant <$>"} # 16 hints
- ignore: {name: "Redundant =="} # 1 hint
- ignore: {name: "Redundant bracket"} # 239 hints
- ignore: {name: "Redundant bracket"} # 240 hints
- ignore: {name: "Redundant fmap"} # 1 hint
- ignore: {name: "Redundant guard"} # 2 hints
- ignore: {name: "Redundant if"} # 6 hints
Expand Down Expand Up @@ -48,9 +48,8 @@
- ignore: {name: "Use concatMap"} # 2 hints
- ignore: {name: "Use const"} # 36 hints
- ignore: {name: "Use elem"} # 2 hints
- ignore: {name: "Use fewer imports"} # 13 hints
- ignore: {name: "Use first"} # 4 hints
- ignore: {name: "Use fmap"} # 26 hints
- ignore: {name: "Use fmap"} # 25 hints
- ignore: {name: "Use fold"} # 1 hint
- ignore: {name: "Use for"} # 1 hint
- ignore: {name: "Use forM_"} # 1 hint
Expand All @@ -66,7 +65,7 @@
- ignore: {name: "Use isNothing"} # 1 hint
- ignore: {name: "Use lambda-case"} # 55 hints
- ignore: {name: "Use lefts"} # 1 hint
- ignore: {name: "Use list comprehension"} # 18 hints
- ignore: {name: "Use list comprehension"} # 19 hints
- ignore: {name: "Use list literal"} # 3 hints
- ignore: {name: "Use list literal pattern"} # 11 hints
- ignore: {name: "Use map once"} # 7 hints
Expand Down Expand Up @@ -95,6 +94,8 @@

- arguments:
- --ignore-glob=Cabal-syntax/src/Distribution/Fields/Lexer.hs
- --ignore-glob=Cabal-tests/tests/custom-setup/CabalDoctestSetup.hs
- --ignore-glob=Cabal-tests/tests/custom-setup/IdrisSetup.hs
- --ignore-glob=cabal-testsuite/PackageTests/BuildWays/q/app/Main.hs
- --ignore-glob=cabal-testsuite/PackageTests/CmmSources/src/Demo.hs
- --ignore-glob=cabal-testsuite/PackageTests/CmmSourcesDyn/src/Demo.hs
Expand Down
4 changes: 2 additions & 2 deletions Cabal/src/Distribution/Compat/Internal/TempFile.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ import System.FilePath ((</>))
import System.IO (Handle, openBinaryTempFile, openTempFile)
#if defined(__IO_MANAGER_WINIO__)
import System.IO (openBinaryTempFileWithDefaultPermissions)
import System.Posix.Internals (c_getpid)
#else
import Control.Exception (onException)
import Data.Bits ((.|.))
import Foreign.C (CInt, eEXIST, getErrno, errnoToIOError)
import GHC.IO.Handle.FD (fdToHandle)
import System.Posix.Internals (c_open, c_close, o_EXCL, o_BINARY, withFilePath,
import System.Posix.Internals (c_getpid, c_open, c_close, o_EXCL, o_BINARY, withFilePath,
o_CREAT, o_RDWR, o_NONBLOCK, o_NOCTTY)
#endif

import System.IO.Error (isAlreadyExistsError)
import System.Posix.Internals (c_getpid)

#if defined(mingw32_HOST_OS) || defined(ghcjs_HOST_OS)
import System.Directory ( createDirectory )
Expand Down
9 changes: 5 additions & 4 deletions Cabal/src/Distribution/Compat/Time.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,14 @@ import System.Win32.Types ( BOOL, DWORD, LPCTSTR, LPVOID, withTString )

#else

import System.Posix.Files ( FileStatus, getFileStatus )

import System.Posix.Files
( FileStatus, getFileStatus
#if MIN_VERSION_unix(2,6,0)
import System.Posix.Files ( modificationTimeHiRes )
, modificationTimeHiRes
#else
import System.Posix.Files ( modificationTime )
, modificationTime
#endif
)

#endif

Expand Down
23 changes: 14 additions & 9 deletions Cabal/src/Distribution/Simple/GHC.hs
Original file line number Diff line number Diff line change
Expand Up @@ -124,24 +124,29 @@ import Distribution.Utils.Path
import Distribution.Verbosity
import Distribution.Version
import Language.Haskell.Extension
import System.Directory
( canonicalizePath
, createDirectoryIfMissing
, doesDirectoryExist
, doesFileExist
, getAppUserDataDirectory
, getDirectoryContents
)
import System.FilePath
( isRelative
, takeDirectory
)
import qualified System.Info
#ifndef mingw32_HOST_OS
import System.Directory (renameFile)
import System.Posix (createSymbolicLink)
#endif /* mingw32_HOST_OS */

{- FOURMOLU_DISABLE -}
import System.Directory
( canonicalizePath
, createDirectoryIfMissing
, doesDirectoryExist
, doesFileExist
, getAppUserDataDirectory
, getDirectoryContents
#ifndef mingw32_HOST_OS
, renameFile
#endif
)
{- FOURMOLU_ENABLE -}

import Distribution.Simple.Setup (BuildingWhat (..))
import Distribution.Simple.Setup.Build

Expand Down
4 changes: 2 additions & 2 deletions cabal-install/src/Distribution/Client/CmdTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ import Distribution.Client.NixStyleOptions
)
import Distribution.Client.ProjectOrchestration
import Distribution.Client.Setup
( ConfigFlags (..)
( CommonSetupFlags (..)
, ConfigFlags (..)
, GlobalFlags (..)
)
import Distribution.Client.TargetProblem
Expand Down Expand Up @@ -66,7 +67,6 @@ import Distribution.Verbosity
import qualified System.Exit (exitSuccess)

import Distribution.Client.Errors
import Distribution.Client.Setup (CommonSetupFlags (..))
import GHC.Environment
( getFullArgs
)
Expand Down
8 changes: 4 additions & 4 deletions cabal-install/src/Distribution/Client/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ module Distribution.Client.Config
) where

import Distribution.Client.Compat.Prelude
import Distribution.Compat.Environment (lookupEnv)
import Distribution.Compat.Environment
( getEnvironment
, lookupEnv
)
import Prelude ()

import Language.Haskell.Extension (Language (Haskell2010))
Expand Down Expand Up @@ -126,9 +129,6 @@ import Distribution.Client.Version
( cabalInstallVersion
)
import qualified Distribution.Compat.CharParsing as P
import Distribution.Compat.Environment
( getEnvironment
)
import Distribution.Compiler
( CompilerFlavor (..)
, defaultCompilerFlavor
Expand Down
15 changes: 12 additions & 3 deletions cabal-install/src/Distribution/Client/ProjectPlanning.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE LambdaCase #-}
Expand Down Expand Up @@ -99,7 +98,18 @@ module Distribution.Client.ProjectPlanning
) where

import Distribution.Client.Compat.Prelude
import Text.PrettyPrint (render)
import Text.PrettyPrint
( colon
, comma
, fsep
, hang
, punctuate
, quotes
, render
, text
, vcat
, ($$)
)
import Prelude ()

import Distribution.Client.Config
Expand Down Expand Up @@ -222,7 +232,6 @@ import qualified Data.Set as Set
import Distribution.Client.Errors
import Distribution.Solver.Types.ProjectConfigPath
import System.FilePath
import Text.PrettyPrint (colon, comma, fsep, hang, punctuate, quotes, text, vcat, ($$))
import qualified Text.PrettyPrint as Disp

-- | Check that an 'ElaboratedConfiguredPackage' actually makes
Expand Down
6 changes: 4 additions & 2 deletions cabal-install/src/Distribution/Client/SetupWrapper.hs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,10 @@ import Distribution.Simple.Program.GHC
, renderGhcOptions
)
import Distribution.Simple.Setup
( Flag (..), CommonSetupFlags (..), GlobalFlags (..)
( CommonSetupFlags (..)
, Flag (..)
, GlobalFlags (..)
, globalCommand
)
import Distribution.Simple.Utils
( cabalVersion
Expand Down Expand Up @@ -175,7 +178,6 @@ import Distribution.Verbosity

import Data.List (foldl1')
import qualified Data.Map.Lazy as Map
import Distribution.Simple.Setup (globalCommand)
import Distribution.Client.Compat.ExecutablePath (getExecutablePath)
import Distribution.Compat.Process (proc)
import System.Directory (doesFileExist)
Expand Down
3 changes: 1 addition & 2 deletions cabal-install/src/Distribution/Client/Store.hs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ import System.FilePath
import Lukko
#else
import System.IO (openFile, IOMode(ReadWriteMode), hClose)
import GHC.IO.Handle.Lock (hLock, hTryLock, LockMode(ExclusiveLock))
import GHC.IO.Handle.Lock (hUnlock)
import GHC.IO.Handle.Lock (LockMode (ExclusiveLock), hLock, hTryLock, hUnlock)
#endif

-- $concurrency
Expand Down
7 changes: 5 additions & 2 deletions cabal-install/tests/IntegrationTests2.hs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ import qualified Distribution.Client.CmdTest as CmdTest

import qualified Distribution.Client.CmdHaddockProject as CmdHaddockProject
import Distribution.Client.Config (SavedConfig (savedGlobalFlags), createDefaultConfigFile, loadConfig)
import Distribution.Client.GlobalFlags (defaultGlobalFlags)
import Distribution.Client.GlobalFlags
( GlobalFlags
, defaultGlobalFlags
, globalNix
)
import Distribution.Client.Setup (globalCommand, globalStoreDir)
import Distribution.InstalledPackageInfo (InstalledPackageInfo)
import Distribution.ModuleName (ModuleName)
Expand Down Expand Up @@ -90,7 +94,6 @@ import Test.Tasty.Options

import qualified Data.ByteString as BS
import Data.Maybe (fromJust)
import Distribution.Client.GlobalFlags (GlobalFlags, globalNix)
import Distribution.Simple.Flag (Flag (Flag, NoFlag))
import Distribution.Types.ParStrat

Expand Down
4 changes: 0 additions & 4 deletions cabal-testsuite/src/Test/Cabal/Monad.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE ScopedTypeVariables #-}

-- | The test monad
Expand Down Expand Up @@ -88,9 +87,6 @@ import Distribution.Verbosity
import Distribution.Version

import Control.Concurrent.Async
#if !MIN_VERSION_base(4,11,0)
import Data.Monoid ((<>))
#endif
import Data.Monoid (mempty)
import qualified Control.Exception as E
import Control.Monad
Expand Down
3 changes: 1 addition & 2 deletions cabal-testsuite/src/Test/Cabal/NeedleHaystack.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ module Test.Cabal.NeedleHaystack

import Prelude hiding (unlines)
import qualified Prelude (unlines)
import Data.List (tails)
import Data.Maybe (isJust)
import Distribution.System
import Distribution.Utils.Generic (unsnoc)
import Data.List (isPrefixOf)
import Data.List (isPrefixOf, tails)
import qualified System.FilePath.Posix as Posix
import qualified System.FilePath.Windows as Windows
import Network.URI (parseURI)
Expand Down
Loading