Skip to content

Easy hlint fixes #1226

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

Merged
merged 5 commits into from
Jan 19, 2021
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
2 changes: 1 addition & 1 deletion GenChangelogs.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ main = do
forM_ prsAfterLastTag $ \SimplePullRequest{..} ->
putStrLn $ T.unpack $ "- " <> simplePullRequestTitle <>
"\n([#" <> T.pack (show $ unIssueNumber simplePullRequestNumber) <> ")](" <> getUrl simplePullRequestHtmlUrl <> ")" <>
" by @" <> (untagName (simpleUserLogin simplePullRequestUser))
" by @" <> untagName (simpleUserLogin simplePullRequestUser)
4 changes: 2 additions & 2 deletions exe/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ main = withUtf8 $ do

let withExamples =
case args of
LspMode (LspArguments{..}) -> argsExamplePlugin
_ -> False
LspMode LspArguments{..} -> argsExamplePlugin
_ -> False

defaultMain args (idePlugins withExamples)
5 changes: 2 additions & 3 deletions exe/Wrapper.hs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ launchHaskellLanguageServer LspArguments{..} = do
hPutStrLn stderr $ showProgramVersionOfInterest programsOfInterest
hPutStrLn stderr ""
-- Get the ghc version -- this might fail!
hPutStrLn stderr $ "Consulting the cradle to get project GHC version..."
hPutStrLn stderr "Consulting the cradle to get project GHC version..."
ghcVersion <- getRuntimeGhcVersion' cradle
hPutStrLn stderr $ "Project GHC version: " ++ ghcVersion

Expand Down Expand Up @@ -136,12 +136,11 @@ getRuntimeGhcVersion' cradle = do
-- of the project that may or may not be accurate.
findLocalCradle :: FilePath -> IO (Cradle Void)
findLocalCradle fp = do
cradleConf <- (findCradle defaultLoadingOptions) fp
cradleConf <- findCradle defaultLoadingOptions fp
crdl <- case cradleConf of
Just yaml -> do
hPutStrLn stderr $ "Found \"" ++ yaml ++ "\" for \"" ++ fp ++ "\""
loadCradle yaml
Nothing -> loadImplicitCradle fp
hPutStrLn stderr $ "Module \"" ++ fp ++ "\" is loaded by Cradle: " ++ show crdl
return crdl

2 changes: 1 addition & 1 deletion ghcide/test/src/Development/IDE/Test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ checkDiagnosticsForDoc :: TextDocumentIdentifier -> [(DiagnosticSeverity, Cursor
checkDiagnosticsForDoc TextDocumentIdentifier {_uri} expected obtained = do
let expected' = Map.fromList [(nuri, map (\(ds, c, t) -> (ds, c, t, Nothing)) expected)]
nuri = toNormalizedUri _uri
expectDiagnosticsWithTags' (return $ (_uri, List obtained)) expected'
expectDiagnosticsWithTags' (return (_uri, List obtained)) expected'

canonicalizeUri :: Uri -> IO Uri
canonicalizeUri uri = filePathToUri <$> canonicalizePath (fromJust (uriToFilePath uri))
Expand Down
4 changes: 2 additions & 2 deletions hie-compat/src-ghc86/Compat/HieBin.hs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ writeHieFile hie_file_path hiefile = do
-- hieVersion and the GHC version used to generate this file
mapM_ (putByte bh0) hieMagic
putBinLine bh0 $ BSC.pack $ show hieVersion
putBinLine bh0 $ ghcVersion
putBinLine bh0 ghcVersion

-- remember where the dictionary pointer will go
dict_p_p <- tellBin bh0
Expand Down Expand Up @@ -297,7 +297,7 @@ getSymbolTable bh ncu = do
getSymTabName :: SymbolTable -> BinHandle -> IO Name
getSymTabName st bh = do
i :: Word32 <- get bh
return $ st A.! (fromIntegral i)
return $ st A.! fromIntegral i

putName :: HieSymbolTable -> BinHandle -> Name -> IO ()
putName (HieSymbolTable next ref) bh name = do
Expand Down
11 changes: 5 additions & 6 deletions hie-compat/src-ghc86/Compat/HieDebug.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{-
Functions to validate and check .hie file ASTs generated by GHC.
-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE FlexibleContexts #-}
module Compat.HieDebug where
Expand All @@ -22,10 +21,10 @@ import Data.Function ( on )
import Data.List ( sortOn )
import Data.Foldable ( toList )

ppHies :: Outputable a => (HieASTs a) -> SDoc
ppHies :: Outputable a => HieASTs a -> SDoc
ppHies (HieASTs asts) = M.foldrWithKey go "" asts
where
go k a rest = vcat $
go k a rest = vcat
[ "File: " <> ppr k
, ppHie a
, rest
Expand Down Expand Up @@ -112,9 +111,9 @@ validAst (Node _ span children) = do
]
checkContainment [] = return ()
checkContainment (x:xs)
| span `containsSpan` (nodeSpan x) = checkContainment xs
| span `containsSpan` nodeSpan x = checkContainment xs
| otherwise = Left $ hsep
[ ppr $ span
[ ppr span
, "does not contain"
, ppr $ nodeSpan x
]
Expand All @@ -139,7 +138,7 @@ validateScopes asts = M.foldrWithKey (\k a b -> valid k a ++ b) [] refMap
[] -> []
_ -> if any (`scopeContainsSpan` sp) scopes
then []
else return $ hsep $
else return $ hsep
[ "Name", ppr n, "at position", ppr sp
, "doesn't occur in calculated scope", ppr scopes]
| otherwise = []
21 changes: 10 additions & 11 deletions hie-compat/src-ghc86/Compat/HieTypes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ For more information see https://gitlab.haskell.org/ghc/ghc/wikis/hie-files
-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# OPTIONS_GHC -Wno-orphans #-}
Expand Down Expand Up @@ -168,7 +167,7 @@ data HieType a
type HieTypeFlat = HieType TypeIndex

-- | Roughly isomorphic to the original core 'Type'.
newtype HieTypeFix = Roll (HieType (HieTypeFix))
newtype HieTypeFix = Roll (HieType HieTypeFix)

instance Binary (HieType TypeIndex) where
put_ bh (HTyVarTy n) = do
Expand Down Expand Up @@ -200,7 +199,7 @@ instance Binary (HieType TypeIndex) where
put_ bh (HCastTy a) = do
putByte bh 7
put_ bh a
put_ bh (HCoercionTy) = putByte bh 8
put_ bh HCoercionTy = putByte bh 8

get bh = do
(t :: Word8) <- get bh
Expand Down Expand Up @@ -228,7 +227,7 @@ instance Binary (HieArgs TypeIndex) where

-- | Mapping from filepaths (represented using 'FastString') to the
-- corresponding AST
newtype HieASTs a = HieASTs { getAsts :: (M.Map FastString (HieAST a)) }
newtype HieASTs a = HieASTs { getAsts :: M.Map FastString (HieAST a) }
deriving (Functor, Foldable, Traversable)

instance Binary (HieASTs TypeIndex) where
Expand Down Expand Up @@ -276,9 +275,9 @@ instance Binary (NodeInfo TypeIndex) where
put_ bh $ nodeType ni
put_ bh $ M.toList $ nodeIdentifiers ni
get bh = NodeInfo
<$> fmap (S.fromDistinctAscList) (get bh)
<$> fmap S.fromDistinctAscList (get bh)
<*> get bh
<*> fmap (M.fromList) (get bh)
<*> fmap M.fromList (get bh)

type Identifier = Either ModuleName Name

Expand Down Expand Up @@ -309,7 +308,7 @@ instance Binary (IdentifierDetails TypeIndex) where
put_ bh $ S.toAscList $ identInfo dets
get bh = IdentifierDetails
<$> get bh
<*> fmap (S.fromDistinctAscList) (get bh)
<*> fmap S.fromDistinctAscList (get bh)


-- | Different contexts under which identifiers exist
Expand Down Expand Up @@ -419,7 +418,7 @@ data IEType

instance Binary IEType where
put_ bh b = putByte bh (fromIntegral (fromEnum b))
get bh = do x <- getByte bh; pure $! (toEnum (fromIntegral x))
get bh = do x <- getByte bh; pure $! toEnum (fromIntegral x)


data RecFieldContext
Expand All @@ -431,7 +430,7 @@ data RecFieldContext

instance Binary RecFieldContext where
put_ bh b = putByte bh (fromIntegral (fromEnum b))
get bh = do x <- getByte bh; pure $! (toEnum (fromIntegral x))
get bh = do x <- getByte bh; pure $! toEnum (fromIntegral x)


data BindType
Expand All @@ -441,7 +440,7 @@ data BindType

instance Binary BindType where
put_ bh b = putByte bh (fromIntegral (fromEnum b))
get bh = do x <- getByte bh; pure $! (toEnum (fromIntegral x))
get bh = do x <- getByte bh; pure $! toEnum (fromIntegral x)


data DeclType
Expand All @@ -456,7 +455,7 @@ data DeclType

instance Binary DeclType where
put_ bh b = putByte bh (fromIntegral (fromEnum b))
get bh = do x <- getByte bh; pure $! (toEnum (fromIntegral x))
get bh = do x <- getByte bh; pure $! toEnum (fromIntegral x)


data Scope
Expand Down
6 changes: 3 additions & 3 deletions hie-compat/src-ghc86/Compat/HieUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ resolveVisibility kind ty_args
ts' = go (extendTvSubst env tv t) res ts

go env (FunTy _ res) (t:ts) -- No type-class args in tycon apps
= (True,t) : (go env res ts)
= (True,t) : go env res ts

go env (TyVarTy tv) ts
| Just ki <- lookupTyVar env tv = go env ki ts
go env kind (t:ts) = (True, t) : (go env kind ts) -- Ill-kinded
go env kind (t:ts) = (True, t) : go env kind ts -- Ill-kinded

foldType :: (HieType a -> a) -> HieTypeFix -> a
foldType f (Roll t) = f $ fmap (foldType f) t
Expand Down Expand Up @@ -114,7 +114,7 @@ compressTypes
-> (HieASTs TypeIndex, A.Array TypeIndex HieTypeFlat)
compressTypes asts = (a, arr)
where
(a, (HTS _ m i)) = flip runState initialHTS $
(a, HTS _ m i) = flip runState initialHTS $
for asts $ \typ -> do
i <- getTypeIndex typ
return i
Expand Down
1 change: 0 additions & 1 deletion hls-plugin-api/src/Ide/Types.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{-# LANGUAGE GADTs #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}

module Ide.Types
Expand Down
2 changes: 1 addition & 1 deletion install/src/Cabal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ getGhcPathOfOrThrowError versionNumber =

cabalInstallHls :: VersionNumber -> [String] -> Action ()
cabalInstallHls versionNumber args = do
localBin <- liftIO $ getInstallDir
localBin <- liftIO getInstallDir
cabalVersion <- getCabalVersion args
ghcPath <- getGhcPathOfOrThrowError versionNumber

Expand Down
6 changes: 3 additions & 3 deletions install/src/HlsInstall.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ defaultMain = do
let args = [verbosityArg (shakeVerbosity shakeOptionsRules)]

phony "show-options" $ do
putNormal $ "Options:"
putNormal "Options:"
putNormal $ " Verbosity level: " ++ show (shakeVerbosity shakeOptionsRules)

want ["short-help"]
Expand All @@ -51,7 +51,7 @@ defaultMain = do
phony "data" $ do
need ["show-options"]
need ["check"]
liftIO $ putStrLn "Generation of hoogle data files is disabled for now."
liftIO $ putStrLn "Generation of hoogle data files is disabled for now."
-- if isRunFromStack then stackBuildData args else cabalBuildData args

forM_
Expand Down Expand Up @@ -90,7 +90,7 @@ defaultMain = do
need ["icu-macos-fix-build"]

phony "icu-macos-fix-install" (command_ [] "brew" ["install", "icu4c"])
phony "icu-macos-fix-build" $ mapM_ (flip buildIcuMacosFix $ args) versions
phony "icu-macos-fix-build" $ mapM_ (flip buildIcuMacosFix args) versions


buildIcuMacosFix :: VersionNumber -> [String] -> Action ()
Expand Down
2 changes: 1 addition & 1 deletion plugins/default/src/Ide/Plugin/Example.hs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ codeLens _lf ideState plId CodeLensParams{_textDocument=TextDocumentIdentifier u
-- edit = WorkspaceEdit (Just $ Map.singleton uri $ List tedit) Nothing
range = Range (Position 3 0) (Position 4 0)
let cmdParams = AddTodoParams uri "do abc"
cmd <- mkLspCommand plId "codelens.todo" title (Just [(toJSON cmdParams)])
cmd <- mkLspCommand plId "codelens.todo" title (Just [toJSON cmdParams])
pure $ Right $ List [ CodeLens range (Just cmd) Nothing ]
Nothing -> pure $ Right $ List []

Expand Down
3 changes: 0 additions & 3 deletions plugins/default/src/Ide/Plugin/Floskell.hs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE ViewPatterns #-}

module Ide.Plugin.Floskell
(
Expand Down
2 changes: 1 addition & 1 deletion plugins/default/src/Ide/Plugin/Fourmolu.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{-# LANGUAGE DisambiguateRecordFields #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PackageImports #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeApplications #-}

module Ide.Plugin.Fourmolu (
Expand Down
1 change: 0 additions & 1 deletion plugins/default/src/Ide/Plugin/Ormolu.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PackageImports #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}

Expand Down
1 change: 0 additions & 1 deletion plugins/hls-eval-plugin/src/Ide/Plugin/Eval/CodeLens.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
{-# LANGUAGE ExtendedDefaultRules #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE ImplicitParams #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ langOptions = runParser (many space *> languageOpts <* many space)
-- >>> runParser languageOpts ":set -XBinaryLiterals -XOverloadedStrings"
-- Right ["BinaryLiterals","OverloadedStrings"]
languageOpts :: Parser Char [[Char]]
languageOpts = string ":set" *> many (many space *> string "-X" *> (many letterChar))
languageOpts = string ":set" *> many (many space *> string "-X" *> many letterChar)
1 change: 0 additions & 1 deletion plugins/hls-eval-plugin/src/Ide/Plugin/Eval/Util.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{-# LANGUAGE ImplicitParams #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE NoMonomorphismRestriction #-}
{-# OPTIONS_GHC -Wno-orphans #-}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE ViewPatterns #-}

#include "ghc-api-version.h"

Expand Down Expand Up @@ -189,10 +187,10 @@ minimalImportsRule = define $ \MinimalImports nfp -> do

-- | Use the ghc api to extract a minimal, explicit set of imports for this module
extractMinimalImports ::
Maybe (HscEnvEq) ->
Maybe (TcModuleResult) ->
Maybe HscEnvEq ->
Maybe TcModuleResult ->
IO ([LImportDecl GhcRn], Maybe [LImportDecl GhcRn])
extractMinimalImports (Just (hsc)) (Just (TcModuleResult {..})) = do
extractMinimalImports (Just hsc) (Just TcModuleResult {..}) = do
-- extract the original imports and the typechecking environment
let tcEnv = tmrTypechecked
(_, imports, _, _) = tmrRenamed
Expand Down
3 changes: 0 additions & 3 deletions plugins/hls-hlint-plugin/src/Ide/Plugin/Hlint.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PackageImports #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE ViewPatterns #-}

module Ide.Plugin.Hlint
(
Expand Down
Loading