Skip to content

Commit 045ecb4

Browse files
Hlint hints.
1 parent 6576637 commit 045ecb4

File tree

6 files changed

+11
-19
lines changed

6 files changed

+11
-19
lines changed

ghcide/.hlint.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
- ignore: {name: "Use uncurry"}
2525
- ignore: {name: "Avoid lambda using `infix`"}
2626

27+
# Gives at least one suggestion we don't like.
28+
- ignore: {name: "Use <=<"}
29+
2730
# We are using the "redundant" return/pure to assign a name. We do not want to
2831
# delete it. In particular, this is not an improvement:
2932
# Found:

plugins/hls-eval-plugin/src/Ide/Plugin/Eval/CodeLens.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import Data.List
4242
(dropWhileEnd,
4343
find, intercalate
4444
)
45+
import Data.List.Extra (zipFrom)
4546
import qualified Data.Map.Strict as Map
4647
import Data.Maybe
4748
( catMaybes,
@@ -405,7 +406,7 @@ moduleText uri =
405406
testsBySection :: [Section] -> [(Section, EvalId, Test)]
406407
testsBySection sections =
407408
[(section, ident, test)
408-
| (ident, section) <- zip [0..] sections
409+
| (ident, section) <- zipFrom 0 sections
409410
, test <- sectionTests section
410411
]
411412

plugins/hls-eval-plugin/src/Ide/Plugin/Eval/Types.hs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ where
3232
import Control.DeepSeq (NFData (rnf), deepseq)
3333
import Data.Aeson (FromJSON, ToJSON)
3434
import Data.List (partition)
35+
import Data.List.Extra (zipWithFrom)
3536
import Data.List.NonEmpty (NonEmpty)
3637
import Data.Map.Strict (Map)
3738
import Data.String (IsString (..))
@@ -55,10 +56,8 @@ type Loc = Located Line
5556

5657
type Line = Int
5758

58-
{- HLINT ignore locate "Use zipWithFrom" -}
59-
6059
locate :: Loc [a] -> [Loc a]
61-
locate (Located l tst) = zipWith Located [l ..] tst
60+
locate (Located l tst) = zipWithFrom Located l tst
6261

6362
locate0 :: [a] -> [Loc a]
6463
locate0 = locate . Located 0

plugins/hls-tactics-plugin/src/Ide/Plugin/Tactic.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
{-# LANGUAGE NumDecimals #-}
66
{-# LANGUAGE OverloadedStrings #-}
77
{-# LANGUAGE ScopedTypeVariables #-}
8-
{-# LANGUAGE TupleSections #-}
98
{-# LANGUAGE ViewPatterns #-}
109

1110
-- | A plugin that uses tactics to synthesize code

plugins/hls-tactics-plugin/src/Ide/Plugin/Tactic/Context.hs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ import TcRnTypes
2121
import TcType (substTy, tcSplitSigmaTy)
2222
import Unify (tcUnifyTy)
2323

24-
25-
{- HLINT ignore mkContext "Redundant fmap" -}
26-
{- HLINT ignore mkContext "Use <=<" -}
24+
{- HLINT ignore module "Redundant fmap" -}
2725

2826
mkContext :: [(OccName, CType)] -> TcGblEnv -> Context
2927
mkContext locals tcg = Context
@@ -36,9 +34,6 @@ mkContext locals tcg = Context
3634
}
3735

3836

39-
40-
{- HLINT ignore contextMethodHypothesis "Redundant fmap" -}
41-
4237
------------------------------------------------------------------------------
4338
-- | Find all of the class methods that exist from the givens in the context.
4439
contextMethodHypothesis :: Context -> Hypothesis CType

plugins/hls-tactics-plugin/src/Ide/Plugin/Tactic/Judgements.hs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import Data.Bool
3535
import Data.Char
3636
import Data.Coerce
3737
import Data.Generics.Product (field)
38+
import Data.List.Extra (zipFrom)
3839
import Data.Map (Map)
3940
import qualified Data.Map as M
4041
import Data.Maybe
@@ -89,8 +90,6 @@ withNewGoal :: a -> Judgement' a -> Judgement' a
8990
withNewGoal t = field @"_jGoal" .~ t
9091

9192

92-
{- HLINT ignore introducing "Use zipFrom" -}
93-
9493
------------------------------------------------------------------------------
9594
-- | Helper function for implementing functions which introduce new hypotheses.
9695
introducing
@@ -100,7 +99,7 @@ introducing
10099
-> Judgement' a
101100
-> Judgement' a
102101
introducing f ns =
103-
field @"_jHypothesis" <>~ (Hypothesis $ zip [0..] ns <&>
102+
field @"_jHypothesis" <>~ (Hypothesis $ zipFrom 0 ns <&>
104103
\(pos, (name, ty)) -> HyInfo name (f pos) ty)
105104

106105

@@ -218,15 +217,11 @@ filterSameTypeFromOtherPositions dcon pos jdg =
218217
in disallowing Shadowed (M.keys to_remove) jdg
219218

220219

221-
{- HLINT ignore getAncestry "Replace case with maybe" -}
222-
223220
------------------------------------------------------------------------------
224221
-- | Return the ancestry of a 'PatVal', or 'mempty' otherwise.
225222
getAncestry :: Judgement' a -> OccName -> Set OccName
226223
getAncestry jdg name =
227-
case M.lookup name $ jPatHypothesis jdg of
228-
Just pv -> pv_ancestry pv
229-
Nothing -> mempty
224+
maybe mempty pv_ancestry (M.lookup name $ jPatHypothesis jdg)
230225

231226

232227
jAncestryMap :: Judgement' a -> Map OccName (Set OccName)

0 commit comments

Comments
 (0)