Skip to content

Commit 53e6ea9

Browse files
authored
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
1 parent 00d914e commit 53e6ea9

File tree

5 files changed

+12
-13
lines changed

5 files changed

+12
-13
lines changed

fmt.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/usr/bin/env bash
22
set -eou pipefail
3-
curl -sSL https://raw.github.com/ndmitchell/hlint/master/misc/run.sh | sh -s .
3+
curl -sSL https://raw.github.com/ndmitchell/hlint/master/misc/run.sh | sh -s . --with-group=extra

src/Development/IDE/Plugin/CodeAction.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ topOfHoleFitsMarker =
343343

344344
mkRenameEdit :: Maybe T.Text -> Range -> T.Text -> TextEdit
345345
mkRenameEdit contents range name =
346-
if fromMaybe False maybeIsInfixFunction
346+
if maybeIsInfixFunction == Just True
347347
then TextEdit range ("`" <> name <> "`")
348348
else TextEdit range name
349349
where

src/Development/IDE/Plugin/Completions/Logic.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ mkImportCompl enteredQual label =
195195
CompletionItem m (Just CiModule) (Just label)
196196
Nothing Nothing Nothing Nothing Nothing Nothing Nothing
197197
Nothing Nothing Nothing Nothing Nothing
198-
where
198+
where
199199
m = fromMaybe "" (T.stripPrefix enteredQual label)
200200

201201
mkExtCompl :: T.Text -> CompletionItem
@@ -303,7 +303,7 @@ toggleSnippets ClientCapabilities { _textDocument } (WithSnippets with) x
303303
| otherwise = x { _insertTextFormat = Just PlainText
304304
, _insertText = Nothing
305305
}
306-
where supported = fromMaybe False (_textDocument >>= _completion >>= _completionItem >>= _snippetSupport)
306+
where supported = Just True == (_textDocument >>= _completion >>= _completionItem >>= _snippetSupport)
307307

308308
-- | Returns the cached completions for the given module and position.
309309
getCompletions :: IdeOptions -> CachedCompletions -> TypecheckedModule -> VFS.PosPrefixInfo -> ClientCapabilities -> WithSnippets -> IO [CompletionItem]
@@ -394,7 +394,7 @@ getCompletions ideOpts CC { allModNamesAsNS, unqualCompls, qualCompls, importabl
394394
= filtModNameCompls ++ map (toggleSnippets caps withSnippets
395395
. mkCompl ideOpts . stripAutoGenerated) filtCompls
396396
++ filtKeywordCompls
397-
397+
398398
return result
399399

400400
-- The supported languages and extensions
@@ -404,7 +404,7 @@ languagesAndExts = map T.pack $ DynFlags.supportedLanguagesAndExtensions ( Platf
404404
#else
405405
languagesAndExts = map T.pack DynFlags.supportedLanguagesAndExtensions
406406
#endif
407-
407+
408408
-- ---------------------------------------------------------------------
409409
-- helper functions for pragmas
410410
-- ---------------------------------------------------------------------

src/Development/IDE/Spans/Common.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ module Development.IDE.Spans.Common (
1818
import Data.Data
1919
import qualified Data.Generics
2020
import qualified Data.Text as T
21+
import Data.List.Extra
2122

2223
import GHC
2324
import Outputable
@@ -28,7 +29,6 @@ import DataCon
2829
import Var
2930
#endif
3031

31-
import Data.Char (isSpace)
3232
import qualified Documentation.Haddock.Parser as H
3333
import qualified Documentation.Haddock.Types as H
3434

@@ -135,9 +135,9 @@ haddockToMarkdown (H.DocHeader (H.Header level title))
135135
= replicate level '#' ++ " " ++ haddockToMarkdown title
136136

137137
haddockToMarkdown (H.DocUnorderedList things)
138-
= '\n' : (unlines $ map (("+ " ++) . dropWhile isSpace . splitForList . haddockToMarkdown) things)
138+
= '\n' : (unlines $ map (("+ " ++) . trimStart . splitForList . haddockToMarkdown) things)
139139
haddockToMarkdown (H.DocOrderedList things)
140-
= '\n' : (unlines $ map (("1. " ++) . dropWhile isSpace . splitForList . haddockToMarkdown) things)
140+
= '\n' : (unlines $ map (("1. " ++) . trimStart . splitForList . haddockToMarkdown) things)
141141
haddockToMarkdown (H.DocDefList things)
142142
= '\n' : (unlines $ map (\(term, defn) -> "+ **" ++ haddockToMarkdown term ++ "**: " ++ haddockToMarkdown defn) things)
143143

@@ -159,4 +159,4 @@ splitForList :: String -> String
159159
splitForList s
160160
= case lines s of
161161
[] -> ""
162-
(first:rest) -> unlines $ first : map ((" " ++) . dropWhile isSpace) rest
162+
(first:rest) -> unlines $ first : map ((" " ++) . trimStart) rest

src/Development/IDE/Types/Options.hs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ module Development.IDE.Types.Options
1414
, defaultIdeOptions
1515
) where
1616

17-
import Data.Maybe
1817
import Development.Shake
1918
import Development.IDE.GHC.Util
2019
import GHC hiding (parseModule, typecheckModule)
@@ -68,8 +67,8 @@ newtype IdeReportProgress = IdeReportProgress Bool
6867
newtype IdeDefer = IdeDefer Bool
6968

7069
clientSupportsProgress :: LSP.ClientCapabilities -> IdeReportProgress
71-
clientSupportsProgress caps = IdeReportProgress $ fromMaybe False $
72-
LSP._workDoneProgress =<< LSP._window (caps :: LSP.ClientCapabilities)
70+
clientSupportsProgress caps = IdeReportProgress $ Just True ==
71+
(LSP._workDoneProgress =<< LSP._window (caps :: LSP.ClientCapabilities))
7372

7473
defaultIdeOptions :: Action (FilePath -> Action HscEnvEq) -> IdeOptions
7574
defaultIdeOptions session = IdeOptions

0 commit comments

Comments
 (0)