Enable compatibility with the next version of HLint (#434)

* Use Just True == in preference to fromMaybe True or similar

* Use trimStart instead of dropWhile isSpace

* Whitespace only

* Remove a redundant import

* Enable HLint hints suggesting the extra library
This commit is contained in:
Neil Mitchell 2020-02-17 09:50:30 +00:00 committed by GitHub
parent 00d914efa7
commit 53e6ea9aa9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 12 additions and 13 deletions

2
fmt.sh
View File

@ -1,3 +1,3 @@
#!/usr/bin/env bash
set -eou pipefail
curl -sSL https://raw.github.com/ndmitchell/hlint/master/misc/run.sh | sh -s .
curl -sSL https://raw.github.com/ndmitchell/hlint/master/misc/run.sh | sh -s . --with-group=extra

View File

@ -343,7 +343,7 @@ topOfHoleFitsMarker =
mkRenameEdit :: Maybe T.Text -> Range -> T.Text -> TextEdit
mkRenameEdit contents range name =
if fromMaybe False maybeIsInfixFunction
if maybeIsInfixFunction == Just True
then TextEdit range ("`" <> name <> "`")
else TextEdit range name
where

View File

@ -195,7 +195,7 @@ mkImportCompl enteredQual label =
CompletionItem m (Just CiModule) (Just label)
Nothing Nothing Nothing Nothing Nothing Nothing Nothing
Nothing Nothing Nothing Nothing Nothing
where
where
m = fromMaybe "" (T.stripPrefix enteredQual label)
mkExtCompl :: T.Text -> CompletionItem
@ -303,7 +303,7 @@ toggleSnippets ClientCapabilities { _textDocument } (WithSnippets with) x
| otherwise = x { _insertTextFormat = Just PlainText
, _insertText = Nothing
}
where supported = fromMaybe False (_textDocument >>= _completion >>= _completionItem >>= _snippetSupport)
where supported = Just True == (_textDocument >>= _completion >>= _completionItem >>= _snippetSupport)
-- | Returns the cached completions for the given module and position.
getCompletions :: IdeOptions -> CachedCompletions -> TypecheckedModule -> VFS.PosPrefixInfo -> ClientCapabilities -> WithSnippets -> IO [CompletionItem]
@ -394,7 +394,7 @@ getCompletions ideOpts CC { allModNamesAsNS, unqualCompls, qualCompls, importabl
= filtModNameCompls ++ map (toggleSnippets caps withSnippets
. mkCompl ideOpts . stripAutoGenerated) filtCompls
++ filtKeywordCompls
return result
-- The supported languages and extensions
@ -404,7 +404,7 @@ languagesAndExts = map T.pack $ DynFlags.supportedLanguagesAndExtensions ( Platf
#else
languagesAndExts = map T.pack DynFlags.supportedLanguagesAndExtensions
#endif
-- ---------------------------------------------------------------------
-- helper functions for pragmas
-- ---------------------------------------------------------------------

View File

@ -18,6 +18,7 @@ module Development.IDE.Spans.Common (
import Data.Data
import qualified Data.Generics
import qualified Data.Text as T
import Data.List.Extra
import GHC
import Outputable
@ -28,7 +29,6 @@ import DataCon
import Var
#endif
import Data.Char (isSpace)
import qualified Documentation.Haddock.Parser as H
import qualified Documentation.Haddock.Types as H
@ -135,9 +135,9 @@ haddockToMarkdown (H.DocHeader (H.Header level title))
= replicate level '#' ++ " " ++ haddockToMarkdown title
haddockToMarkdown (H.DocUnorderedList things)
= '\n' : (unlines $ map (("+ " ++) . dropWhile isSpace . splitForList . haddockToMarkdown) things)
= '\n' : (unlines $ map (("+ " ++) . trimStart . splitForList . haddockToMarkdown) things)
haddockToMarkdown (H.DocOrderedList things)
= '\n' : (unlines $ map (("1. " ++) . dropWhile isSpace . splitForList . haddockToMarkdown) things)
= '\n' : (unlines $ map (("1. " ++) . trimStart . splitForList . haddockToMarkdown) things)
haddockToMarkdown (H.DocDefList things)
= '\n' : (unlines $ map (\(term, defn) -> "+ **" ++ haddockToMarkdown term ++ "**: " ++ haddockToMarkdown defn) things)
@ -159,4 +159,4 @@ splitForList :: String -> String
splitForList s
= case lines s of
[] -> ""
(first:rest) -> unlines $ first : map ((" " ++) . dropWhile isSpace) rest
(first:rest) -> unlines $ first : map ((" " ++) . trimStart) rest

View File

@ -14,7 +14,6 @@ module Development.IDE.Types.Options
, defaultIdeOptions
) where
import Data.Maybe
import Development.Shake
import Development.IDE.GHC.Util
import GHC hiding (parseModule, typecheckModule)
@ -68,8 +67,8 @@ newtype IdeReportProgress = IdeReportProgress Bool
newtype IdeDefer = IdeDefer Bool
clientSupportsProgress :: LSP.ClientCapabilities -> IdeReportProgress
clientSupportsProgress caps = IdeReportProgress $ fromMaybe False $
LSP._workDoneProgress =<< LSP._window (caps :: LSP.ClientCapabilities)
clientSupportsProgress caps = IdeReportProgress $ Just True ==
(LSP._workDoneProgress =<< LSP._window (caps :: LSP.ClientCapabilities))
defaultIdeOptions :: Action (FilePath -> Action HscEnvEq) -> IdeOptions
defaultIdeOptions session = IdeOptions