Skip to content

Local binding hints (WIP) #4610

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

Draft
wants to merge 35 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
ba2d544
Add sig lens for where clauses
July541 Jun 17, 2022
7bf07ca
Compat
July541 Jun 19, 2022
51ef231
Golden tests
July541 Jun 20, 2022
cd34e8c
Merge branch 'master' into local-binding-type-lens
pepeiborra Jun 24, 2022
c9daf86
Merge branch 'master' into local-binding-type-lens
July541 Dec 10, 2022
232e6ba
Merge remote-tracking branch 'upstream/master' into inlay-hints-local…
jetjinser Jul 27, 2024
f401ff2
Provide where sigs in inlay hints
jetjinser Jul 30, 2024
287f7fa
add offset for FunBind since infix function
jetjinser Jul 31, 2024
228d669
add ghcide InlayHintTests
jetjinser Jul 31, 2024
52ea29f
use liftZonkM in GHC > 9.7.0
jetjinser Jul 31, 2024
e61663d
Fix accidentally broken codeLens
jetjinser Aug 1, 2024
8b6f15e
Add Inlay Hints payload test for type lens
jetjinser Aug 1, 2024
e544187
update testdata schema
jetjinser Aug 1, 2024
5fa456d
Apply suggestions from code review
jetjinser Aug 16, 2024
561d082
refactor: bindToSig just return signature string
jetjinser Aug 17, 2024
b226661
fix: renamed existingSigNames
jetjinser Aug 17, 2024
837ee45
chore: correct schema property `whereInlayHintOn`
jetjinser Aug 17, 2024
96417e0
fix: typo
jetjinser Aug 17, 2024
20e1274
refactor: rewrite where bindings sig as Rules
jetjinser Aug 18, 2024
6d5f4af
Merge remote-tracking branch 'upstream/master' into inlay-hints-local…
jetjinser Aug 21, 2024
efc434b
feat: show local binding instead of just where clause
jetjinser Sep 1, 2024
d065a0a
refactor: correct comment location
jetjinser Sep 1, 2024
2d221d8
ignore things that don't have signatures
jetjinser Sep 1, 2024
953db22
refactor
jetjinser Sep 1, 2024
0df54d2
update local-binding inlayHints config desc
jetjinser Sep 1, 2024
59d56bc
update TypeLenses plugin desc
jetjinser Sep 1, 2024
0e69f46
update TypeLenses test/data dirname
jetjinser Sep 1, 2024
2f27e9a
HsLet compatible
jetjinser Sep 2, 2024
80184f8
Merge remote-tracking branch 'upstream/master' into inlay-hints-local…
jetjinser Sep 2, 2024
94c6841
Merge remote-tracking branch 'upstream/master' into inlay-hints-local…
jetjinser Sep 12, 2024
9cde704
Merge remote-tracking branch 'jetjinser/inlay-hints-local-binding' in…
Jun 2, 2025
330cbe9
fix broken explicit export tests
Jun 3, 2025
d2d8633
allow either code lens or inlay hints for local binds
Jun 3, 2025
a2759f6
default inlay hints to False
Jun 3, 2025
78df62b
Merge remote-tracking branch 'origin/master' into local-binding-hints
Jun 12, 2025
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
7 changes: 7 additions & 0 deletions ghcide-test/data/local-sig-inlay-hints/Infix.expected.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module Infix where

f :: a
f = undefined
where
g :: p1 -> p -> p1
a `g` b = a
6 changes: 6 additions & 0 deletions ghcide-test/data/local-sig-inlay-hints/Infix.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module Infix where

f :: a
f = undefined
where
a `g` b = a
6 changes: 6 additions & 0 deletions ghcide-test/data/local-sig-inlay-hints/Inline.expected.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module Inline where

f :: a
f = undefined
where g :: Bool
g = True
5 changes: 5 additions & 0 deletions ghcide-test/data/local-sig-inlay-hints/Inline.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module Inline where

f :: a
f = undefined
where g = True
10 changes: 10 additions & 0 deletions ghcide-test/data/local-sig-inlay-hints/Nest.expected.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module Nest where

f :: Int
f = g
where
g :: Int
g = h
h :: Int
h = k where k :: Int
k = 3
7 changes: 7 additions & 0 deletions ghcide-test/data/local-sig-inlay-hints/Nest.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module Nest where

f :: Int
f = g
where
g = h
h = k where k = 3
13 changes: 13 additions & 0 deletions ghcide-test/data/local-sig-inlay-hints/NoLens.expected.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module NoLens where

f :: a
f = undefined
where
g = 3






g :: Int
13 changes: 13 additions & 0 deletions ghcide-test/data/local-sig-inlay-hints/NoLens.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module NoLens where

f :: a
f = undefined
where
g = 3






g :: Int
7 changes: 7 additions & 0 deletions ghcide-test/data/local-sig-inlay-hints/Operator.expected.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module Operator where

f :: a
f = undefined
where
g :: (a -> b) -> a -> b
g = ($)
6 changes: 6 additions & 0 deletions ghcide-test/data/local-sig-inlay-hints/Operator.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module Operator where

f :: a
f = undefined
where
g = ($)
9 changes: 9 additions & 0 deletions ghcide-test/data/local-sig-inlay-hints/Qualified.expected.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module Qualified where

import qualified Data.Map as Map

f :: a
f = undefined
where
g :: Map.Map Bool Char
g = Map.singleton True 'c'
8 changes: 8 additions & 0 deletions ghcide-test/data/local-sig-inlay-hints/Qualified.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module Qualified where

import qualified Data.Map as Map

f :: a
f = undefined
where
g = Map.singleton True 'c'
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{-# LANGUAGE ExplicitForAll #-}
module ScopedTypeVariables where

f :: forall a b. a -> b -> (a, b)
f aa bb = (aa, ida bb)
where
ida :: b -> b
ida = id
7 changes: 7 additions & 0 deletions ghcide-test/data/local-sig-inlay-hints/ScopedTypeVariables.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{-# LANGUAGE ExplicitForAll #-}
module ScopedTypeVariables where

f :: forall a b. a -> b -> (a, b)
f aa bb = (aa, ida bb)
where
ida = id
7 changes: 7 additions & 0 deletions ghcide-test/data/local-sig-inlay-hints/Simple.expected.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module Simple where

f :: a
f = undefined
where
g :: Bool
g = True
6 changes: 6 additions & 0 deletions ghcide-test/data/local-sig-inlay-hints/Simple.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module Simple where

f :: a
f = undefined
where
g = True
8 changes: 8 additions & 0 deletions ghcide-test/data/local-sig-inlay-hints/Tuple.expected.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module Typle where

f :: a
f = undefined
where
g :: Integer
h :: Bool
(g, h) = (1, True)
6 changes: 6 additions & 0 deletions ghcide-test/data/local-sig-inlay-hints/Tuple.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module Typle where

f :: a
f = undefined
where
(g, h) = (1, True)
7 changes: 7 additions & 0 deletions ghcide-test/data/local-sig-inlay-hints/Typeclass.expected.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module Typeclass where

f :: a
f = undefined
where
g :: Num a => a -> a -> a
g a b = a + b
6 changes: 6 additions & 0 deletions ghcide-test/data/local-sig-inlay-hints/Typeclass.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module Typeclass where

f :: a
f = undefined
where
g a b = a + b
181 changes: 181 additions & 0 deletions ghcide-test/exe/InlayHintTests.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
{-# LANGUAGE ExplicitNamespaces #-}

module InlayHintTests (tests) where

import Config (mkIdeTestFs, testWithDummyPlugin,
testWithDummyPluginEmpty)
import Control.Monad (void)
import Control.Monad.IO.Class (MonadIO (liftIO))
import qualified Data.Aeson as A
import Data.Maybe (mapMaybe)
import qualified Data.Text as T
import Language.LSP.Protocol.Types (InlayHint (..),
Position (Position),
Range (Range, _end, _start),
TextDocumentIdentifier (TextDocumentIdentifier),
TextEdit (TextEdit, _newText, _range),
UInt,
VersionedTextDocumentIdentifier (_uri),
type (|?) (..))
import Language.LSP.Test (applyEdit, createDoc,
documentContents, getInlayHints,
openDoc, setConfigSection)
import Test.Hls (Assertion, Session, expectFail,
waitForTypecheck)
import Test.Hls.FileSystem (copyDir)
import Test.Tasty (TestTree, testGroup)
import Test.Tasty.HUnit ((@=?), (@?=))

tests :: TestTree
tests = testGroup "inlay hints"
[ whereInlayHintsTests
]

whereInlayHintsTests :: TestTree
whereInlayHintsTests = testGroup "add signature for where clauses"
[ testWithDummyPluginEmpty "No where inlay hints if disabled" $ do
let content = T.unlines
[ "module Sigs where"
, "f :: b"
, "f = undefined"
, " where"
, " g = True"
]
range = Range { _start = Position 4 0
, _end = Position 4 1000
}
doc <- createDoc "Sigs.hs" "haskell" content
setConfigSection "haskell" (createConfig False)
inlayHints <- getInlayHints doc range
liftIO $ length inlayHints @?= 0
, testGroup "apply EditText"
[ editTest "Simple"
, editTest "Tuple"
, editTest "Inline"
, editTest "Infix"
, editTest "Operator"
, expectFail $ editTest "ScopedTypeVariables"
, editTest "Nest"
, editTest "NoLens"
, expectFail $ editTest "Typeclass"
, editTest "Qualified"
]
, testGroup "apply EditText"
[ hintTest "Simple" $ (@=?)
[defInlayHint { _position = Position 5 9
, _label = InL ":: Bool"
, _textEdits = Just [mkTextEdit 5 8 "g :: Bool\n "]
}]
, hintTest "Tuple" $ (@=?)
[ defInlayHint { _position = Position 5 10
, _label = InL ":: Integer"
, _textEdits = Just [mkTextEdit 5 8 "g :: Integer\n "]
}
, defInlayHint { _position = Position 5 13
, _label = InL ":: Bool"
, _textEdits = Just [mkTextEdit 5 8 "h :: Bool\n "]
}
]
, hintTest "Inline" $ (@=?)
[defInlayHint { _position = Position 4 11
, _label = InL ":: Bool"
, _textEdits = Just [mkTextEdit 4 10 "g :: Bool\n "]
}]
, hintTest "Infix" $ (@=?)
[defInlayHint { _position = Position 5 13
, _label = InL ":: p1 -> p -> p1"
, _textEdits = Just [mkTextEdit 5 8 "g :: p1 -> p -> p1\n "]
}]
, hintTest "Operator" $ (@=?)
[defInlayHint { _position = Position 5 9
, _label = InL ":: (a -> b) -> a -> b"
, _textEdits = Just [mkTextEdit 5 8 "g :: (a -> b) -> a -> b\n "]
}]
, hintTest "Nest" $ (@=?)
[ defInlayHint { _position = Position 6 9
, _label = InL ":: Int"
, _textEdits = Just [mkTextEdit 6 8 "h :: Int\n "]
}
, defInlayHint { _position = Position 5 9
, _label = InL ":: Int"
, _textEdits = Just [mkTextEdit 5 8 "g :: Int\n "]
}
, defInlayHint { _position = Position 6 21
, _label = InL ":: Int"
, _textEdits = Just [mkTextEdit 6 20 "k :: Int\n "]
}
]
, hintTest "NoLens" $ (@=?) []
, hintTest "Qualified" $ (@=?)
[ defInlayHint { _position = Position 7 10
, _label = InL ":: Map.Map Bool Char"
, _textEdits = Just [mkTextEdit 7 9 "g :: Map.Map Bool Char\n "]
}
]
]
]

editTest :: String -> TestTree
editTest file =
testWithDummyPlugin (file <> " (InlayHint EditText)") (mkIdeTestFs [copyDir "local-sig-inlay-hints"]) $ do
doc <- openDoc (file ++ ".hs") "haskell"
setConfigSection "haskell" (createConfig True)
executeAllHints doc globalRange
real <- documentContents doc
expectedDoc <- openDoc (file ++ ".expected.hs") "haskell"
expected <- documentContents expectedDoc
liftIO $ real @?= expected

hintTest :: String -> ([InlayHint] -> Assertion) -> TestTree
hintTest file assert =
testWithDummyPlugin (file <> " (InlayHint)") (mkIdeTestFs [copyDir "local-sig-inlay-hints"]) $ do
doc <- openDoc (file ++ ".hs") "haskell"
setConfigSection "haskell" (createConfig True)
hints <- getInlayHints doc globalRange
liftIO $ assert hints


createConfig :: Bool -> A.Value
createConfig on =
A.object [ "plugin"
A..= A.object [ "ghcide-type-lenses"
A..= A.object [ "config"
A..= A.object [ "localBindingInlayHintOn" A..= A.Bool on ]]]]


executeAllHints :: TextDocumentIdentifier -> Range -> Session ()
executeAllHints doc range = do
void $ waitForTypecheck doc
hints <- getInlayHints doc range
let edits = concat $ mapMaybe _textEdits hints
case edits of
[] -> pure ()
edit : _ -> do
newDoc <- applyEdit doc edit
executeAllHints (TextDocumentIdentifier $ _uri newDoc) range

defInlayHint :: InlayHint
defInlayHint =
InlayHint { _position = Position 0 0
, _label = InL ""
, _kind = Nothing
, _textEdits = Nothing
, _tooltip = Nothing
, _paddingLeft = Just True
, _paddingRight = Nothing
, _data_ = Nothing
}

mkTextEdit :: UInt -> UInt -> T.Text -> TextEdit
mkTextEdit x y text =
TextEdit { _range = pointRange x y
, _newText = text
}

pointRange :: UInt -> UInt -> Range
pointRange x y = Range (Position x y) (Position x y)

globalRange :: Range
globalRange = Range { _start = Position 0 0
, _end = Position 1000 0
}
4 changes: 3 additions & 1 deletion ghcide-test/exe/Main.hs
Original file line number Diff line number Diff line change
@@ -51,6 +51,7 @@ import HaddockTests
import HighlightTests
import IfaceTests
import InitializeResponseTests
import InlayHintTests
import LogType ()
import NonLspCommandLine
import OpenCloseTest
@@ -81,7 +82,7 @@ main = do
, HighlightTests.tests
, FindDefinitionAndHoverTests.tests
, FindImplementationAndHoverTests.tests
, PluginSimpleTests.tests
-- , PluginSimpleTests.tests
, PreprocessorTests.tests
, THTests.tests
, SymlinkTests.tests
@@ -103,4 +104,5 @@ main = do
, GarbageCollectionTests.tests
, HieDbRetry.tests
, ExceptionTests.tests
, InlayHintTests.tests
]
311 changes: 281 additions & 30 deletions ghcide/src/Development/IDE/Plugin/TypeLenses.hs

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions haskell-language-server.cabal
Original file line number Diff line number Diff line change
@@ -2169,6 +2169,7 @@ test-suite ghcide-tests
THTests
UnitTests
WatchedFileTests
InlayHintTests

-- Tests that have been pulled out of the main file
default-extensions:
4 changes: 3 additions & 1 deletion test/testdata/schema/ghc910/default-config.golden.json
Original file line number Diff line number Diff line change
@@ -86,10 +86,12 @@
"symbolsOn": true
},
"ghcide-type-lenses": {
"codeLensOn": true,
"config": {
"localBindingInlayHintOn": true,
"mode": "always"
},
"globalOn": true
"inlayHintsOn": true
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

regenerate these

},
"hlint": {
"codeActionsOn": true,
16 changes: 14 additions & 2 deletions test/testdata/schema/ghc910/vscode-extension-schema.golden.json
Original file line number Diff line number Diff line change
@@ -191,6 +191,18 @@
"scope": "resource",
"type": "boolean"
},
"haskell.plugin.ghcide-type-lenses.codeLensOn": {
"default": true,
"description": "Enables ghcide-type-lenses code lenses",
"scope": "resource",
"type": "boolean"
},
"haskell.plugin.ghcide-type-lenses.config.localBindingInlayHintOn": {
"default": true,
"markdownDescription": "Display inlay hints of local bindings",
"scope": "resource",
"type": "boolean"
},
"haskell.plugin.ghcide-type-lenses.config.mode": {
"default": "always",
"description": "Control how type lenses are shown",
@@ -207,9 +219,9 @@
"scope": "resource",
"type": "string"
},
"haskell.plugin.ghcide-type-lenses.globalOn": {
"haskell.plugin.ghcide-type-lenses.inlayHintsOn": {
"default": true,
"description": "Enables ghcide-type-lenses plugin",
"description": "Enables ghcide-type-lenses inlay hints",
"scope": "resource",
"type": "boolean"
},
4 changes: 3 additions & 1 deletion test/testdata/schema/ghc912/default-config.golden.json
Original file line number Diff line number Diff line change
@@ -86,10 +86,12 @@
"symbolsOn": true
},
"ghcide-type-lenses": {
"codeLensOn": true,
"config": {
"localBindingInlayHintOn": true,
"mode": "always"
},
"globalOn": true
"inlayHintsOn": true
},
"hlint": {
"codeActionsOn": true,
16 changes: 14 additions & 2 deletions test/testdata/schema/ghc912/vscode-extension-schema.golden.json
Original file line number Diff line number Diff line change
@@ -191,6 +191,18 @@
"scope": "resource",
"type": "boolean"
},
"haskell.plugin.ghcide-type-lenses.codeLensOn": {
"default": true,
"description": "Enables ghcide-type-lenses code lenses",
"scope": "resource",
"type": "boolean"
},
"haskell.plugin.ghcide-type-lenses.config.localBindingInlayHintOn": {
"default": true,
"markdownDescription": "Display inlay hints of local bindings",
"scope": "resource",
"type": "boolean"
},
"haskell.plugin.ghcide-type-lenses.config.mode": {
"default": "always",
"description": "Control how type lenses are shown",
@@ -207,9 +219,9 @@
"scope": "resource",
"type": "string"
},
"haskell.plugin.ghcide-type-lenses.globalOn": {
"haskell.plugin.ghcide-type-lenses.inlayHintsOn": {
"default": true,
"description": "Enables ghcide-type-lenses plugin",
"description": "Enables ghcide-type-lenses inlay hints",
"scope": "resource",
"type": "boolean"
},
4 changes: 3 additions & 1 deletion test/testdata/schema/ghc96/default-config.golden.json
Original file line number Diff line number Diff line change
@@ -86,10 +86,12 @@
"symbolsOn": true
},
"ghcide-type-lenses": {
"codeLensOn": true,
"config": {
"localBindingInlayHintOn": true,
"mode": "always"
},
"globalOn": true
"inlayHintsOn": true
},
"hlint": {
"codeActionsOn": true,
16 changes: 14 additions & 2 deletions test/testdata/schema/ghc96/vscode-extension-schema.golden.json
Original file line number Diff line number Diff line change
@@ -191,6 +191,18 @@
"scope": "resource",
"type": "boolean"
},
"haskell.plugin.ghcide-type-lenses.codeLensOn": {
"default": true,
"description": "Enables ghcide-type-lenses code lenses",
"scope": "resource",
"type": "boolean"
},
"haskell.plugin.ghcide-type-lenses.config.localBindingInlayHintOn": {
"default": true,
"markdownDescription": "Display inlay hints of local bindings",
"scope": "resource",
"type": "boolean"
},
"haskell.plugin.ghcide-type-lenses.config.mode": {
"default": "always",
"description": "Control how type lenses are shown",
@@ -207,9 +219,9 @@
"scope": "resource",
"type": "string"
},
"haskell.plugin.ghcide-type-lenses.globalOn": {
"haskell.plugin.ghcide-type-lenses.inlayHintsOn": {
"default": true,
"description": "Enables ghcide-type-lenses plugin",
"description": "Enables ghcide-type-lenses inlay hints",
"scope": "resource",
"type": "boolean"
},
4 changes: 3 additions & 1 deletion test/testdata/schema/ghc98/default-config.golden.json
Original file line number Diff line number Diff line change
@@ -86,10 +86,12 @@
"symbolsOn": true
},
"ghcide-type-lenses": {
"codeLensOn": true,
"config": {
"localBindingInlayHintOn": true,
"mode": "always"
},
"globalOn": true
"inlayHintsOn": true
},
"hlint": {
"codeActionsOn": true,
16 changes: 14 additions & 2 deletions test/testdata/schema/ghc98/vscode-extension-schema.golden.json
Original file line number Diff line number Diff line change
@@ -191,6 +191,18 @@
"scope": "resource",
"type": "boolean"
},
"haskell.plugin.ghcide-type-lenses.codeLensOn": {
"default": true,
"description": "Enables ghcide-type-lenses code lenses",
"scope": "resource",
"type": "boolean"
},
"haskell.plugin.ghcide-type-lenses.config.localBindingInlayHintOn": {
"default": true,
"markdownDescription": "Display inlay hints of local bindings",
"scope": "resource",
"type": "boolean"
},
"haskell.plugin.ghcide-type-lenses.config.mode": {
"default": "always",
"description": "Control how type lenses are shown",
@@ -207,9 +219,9 @@
"scope": "resource",
"type": "string"
},
"haskell.plugin.ghcide-type-lenses.globalOn": {
"haskell.plugin.ghcide-type-lenses.inlayHintsOn": {
"default": true,
"description": "Enables ghcide-type-lenses plugin",
"description": "Enables ghcide-type-lenses inlay hints",
"scope": "resource",
"type": "boolean"
},

Unchanged files with check annotations Beta

{ source_version = ver
, old_value = m_old
, get_file_version = use GetModificationTime_{missingFileDiagnostics = False}
, get_linkable_hashes = \fs -> map (snd . fromJust . hirCoreFp) <$> uses_ GetModIface fs

Check warning on line 805 in ghcide/src/Development/IDE/Core/Rules.hs

GitHub Actions / Hlint check run

Suggestion in getModIfaceFromDiskRule in module Development.IDE.Core.Rules: Use fmap ▫︎ Found: "\\ fs -> map (snd . fromJust . hirCoreFp) <$> uses_ GetModIface fs" ▫︎ Perhaps: "fmap (map (snd . fromJust . hirCoreFp)) . uses_ GetModIface"
, get_module_graph = useWithSeparateFingerprintRule_ GetModuleGraphTransDepsFingerprints GetModuleGraph f
, regenerate = regenerateHiFile session f ms
}
Just fileDiags -> do
pure $ Just $ filter diagRangeOverlaps fileDiags
where
diagRangeOverlaps = \fileDiag ->

Check warning on line 219 in ghcide/src/Development/IDE/Core/PluginUtils.hs

GitHub Actions / Hlint check run

Warning in activeDiagnosticsInRangeMT in module Development.IDE.Core.PluginUtils: Redundant lambda ▫︎ Found: "diagRangeOverlaps\n = \\ fileDiag\n -> rangesOverlap range (fileDiag ^. fdLspDiagnosticL . LSP.range)" ▫︎ Perhaps: "diagRangeOverlaps fileDiag\n = rangesOverlap range (fileDiag ^. fdLspDiagnosticL . LSP.range)"
rangesOverlap range (fileDiag ^. fdLspDiagnosticL . LSP.range)
-- | Just like 'activeDiagnosticsInRangeMT'. See the docs of 'activeDiagnosticsInRangeMT' for details.
import Data.Time (UTCTime (..))
import Data.Tuple.Extra (dupe)
import Debug.Trace
import Development.IDE.Core.FileStore (resetInterfaceStore)

Check warning on line 73 in ghcide/src/Development/IDE/Core/Compile.hs

GitHub Actions / Hlint check run

Warning in module Development.IDE.Core.Compile: Use fewer imports ▫︎ Found: "import Development.IDE.Core.FileStore ( resetInterfaceStore )\nimport Development.IDE.Core.FileStore ( shareFilePath )\n" ▫︎ Perhaps: "import Development.IDE.Core.FileStore\n ( resetInterfaceStore, shareFilePath )\n"
import Development.IDE.Core.Preprocessor
import Development.IDE.Core.ProgressReporting (progressUpdate)
import Development.IDE.Core.RuleTypes
tcs = tcg_tcs ts :: [TyCon]
hie_asts = GHC.enrichHie all_binds (tmrRenamed tcm) top_ev_binds insts tcs
pure $ Just $

Check warning on line 826 in ghcide/src/Development/IDE/Core/Compile.hs

GitHub Actions / Hlint check run

Suggestion in generateHieAsts in module Development.IDE.Core.Compile: Redundant $ ▫︎ Found: "Just $ hie_asts" ▫︎ Perhaps: "Just hie_asts"
#if MIN_VERSION_ghc(9,11,0)
hie_asts (tcg_type_env ts)
#else
convImport (L _ i) = (
(ideclPkgQual i)

Check warning on line 1106 in ghcide/src/Development/IDE/Core/Compile.hs

GitHub Actions / Hlint check run

Suggestion in getModSummaryFromImports in module Development.IDE.Core.Compile: Redundant bracket ▫︎ Found: "((ideclPkgQual i), reLoc $ ideclName i)" ▫︎ Perhaps: "(ideclPkgQual i, reLoc $ ideclName i)"
, reLoc $ ideclName i)
msrImports = implicit_imports ++ imps
{-# LANGUAGE DeriveAnyClass #-}

Check warning on line 1 in ghcide/session-loader/Development/IDE/Session/Diagnostics.hs

GitHub Actions / Hlint check run

Warning in module Development.IDE.Session.Diagnostics: Use module export list ▫︎ Found: "module Development.IDE.Session.Diagnostics where" ▫︎ Perhaps: "module Development.IDE.Session.Diagnostics (\n module Development.IDE.Session.Diagnostics\n ) where" ▫︎ Note: an explicit list is usually better
module Development.IDE.Session.Diagnostics where
import Control.Applicative
surround start s end = do
guard (listToMaybe s == Just start)
guard (listToMaybe (reverse s) == Just end)
pure $ drop 1 $ take (length s - 1) s

Check warning on line 92 in ghcide/session-loader/Development/IDE/Session/Diagnostics.hs

GitHub Actions / Hlint check run

Warning in parseMultiCradleErr in module Development.IDE.Session.Diagnostics: Use drop1 ▫︎ Found: "drop 1" ▫︎ Perhaps: "drop1"
multiCradleErrMessage :: MultiCradleErr -> [String]
multiCradleErrMessage e =
[] -> error $ "GHC version could not be parsed: " <> version
((runTime, _):_)
| compileTime == runTime -> do
atomicModifyIORef' cradle_files (\xs -> (cfp:xs,()))

Check warning on line 630 in ghcide/session-loader/Development/IDE/Session.hs

GitHub Actions / Hlint check run

Warning in loadSessionWithOptions in module Development.IDE.Session: Use atomicModifyIORef'_ ▫︎ Found: "atomicModifyIORef' cradle_files (\\ xs -> (cfp : xs, ()))" ▫︎ Perhaps: "atomicModifyIORef'_ cradle_files ((:) cfp)"
session (hieYaml, toNormalizedFilePath' cfp, opts, libDir)
| otherwise -> return (([renderPackageSetupException cfp GhcVersionMismatch{..}], Nothing),[])
-- Failure case, either a cradle error or the none cradle
x <- map errMsgDiagnostic closure_errs
DriverHomePackagesNotClosed us <- pure x
pure us
isBad ci = (homeUnitId_ (componentDynFlags ci)) `OS.member` bad_units

Check warning on line 897 in ghcide/session-loader/Development/IDE/Session.hs

GitHub Actions / Hlint check run

Suggestion in newComponentCache in module Development.IDE.Session: Redundant bracket ▫︎ Found: "(homeUnitId_ (componentDynFlags ci)) `OS.member` bad_units" ▫︎ Perhaps: "homeUnitId_ (componentDynFlags ci) `OS.member` bad_units"
-- Whenever we spin up a session on Linux, dynamically load libm.so.6
-- in. We need this in case the binary is statically linked, in which
-- case the interactive session will fail when trying to load
{-# LANGUAGE CPP #-}

Check warning on line 1 in exe/Wrapper.hs

GitHub Actions / Hlint check run

Warning in module Main: Use module export list ▫︎ Found: "module Main where" ▫︎ Perhaps: "module Main (\n module Main\n ) where" ▫︎ Note: an explicit list is usually better
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}