hlint 3.3.2 → 3.3.3
raw patch · 4 files changed
+24/−14 lines, 4 filesdep ~extraPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: extra
API changes (from Hackage documentation)
Files
- CHANGES.txt +3/−0
- hlint.cabal +1/−1
- src/Hint/Fixities.hs +1/−1
- src/Hint/List.hs +19/−12
CHANGES.txt view
@@ -1,5 +1,8 @@ Changelog for HLint (* = breaking change) +3.3.3, released 2021-08-29+ #1286, compatibility with extra-1.7.10+ #114, if OverloadedLists are enabled, don't suggest list literals 3.3.2, released 2021-08-28 #1244, add `only` restriction to modules #1278, make --ignore-glob patterns also ignore directories
hlint.cabal view
@@ -1,7 +1,7 @@ cabal-version: 1.18 build-type: Simple name: hlint-version: 3.3.2+version: 3.3.3 license: BSD3 license-file: LICENSE category: Development
src/Hint/Fixities.hs view
@@ -62,7 +62,7 @@ | i == 0 = (c, p) | otherwise = (p, c) in- case compareFixity <$> (fixities !? occNameString lop) <*> (fixities !? occNameString rop) of+ case compareFixity <$> (fixities Data.Map.!? occNameString lop) <*> (fixities Data.Map.!? occNameString rop) of Just (False, r) | i == 0 -> not (needParenAsChild cr || r) | otherwise -> r
src/Hint/List.hs view
@@ -34,6 +34,8 @@ foo = [x | False, x <- [1 .. 10]] -- [] foo = [_ | x <- _, let _ = A{x}] issue1039 = foo (map f [1 | _ <- []]) -- [f 1 | _ <- []]+{-# LANGUAGE OverloadedLists #-} \+issue114 = True:[] </TEST> -} @@ -45,7 +47,7 @@ import Data.Maybe import Prelude -import Hint.Type(DeclHint,Idea,suggest,ignore,substVars,toRefactSrcSpan,toSS)+import Hint.Type(DeclHint,Idea,suggest,ignore,substVars,toRefactSrcSpan,toSS,ghcAnnotations) import Refact.Types hiding (SrcSpan) import qualified Refact.Types as R@@ -67,11 +69,14 @@ listHint :: DeclHint-listHint _ _ = listDecl+listHint _ modu = listDecl overloadedListsOn+ where+ exts = concatMap snd (languagePragmas (pragmas (ghcAnnotations modu)))+ overloadedListsOn = "OverloadedLists" `elem` exts -listDecl :: LHsDecl GhcPs -> [Idea]-listDecl x =- concatMap (listExp False) (childrenBi x) +++listDecl :: Bool -> LHsDecl GhcPs -> [Idea]+listDecl overloadedListsOn x =+ concatMap (listExp overloadedListsOn False) (childrenBi x) ++ stringType x ++ concatMap listPat (childrenBi x) ++ concatMap listComp (universeBi x)@@ -149,12 +154,14 @@ f guards (x@(L _ LetStmt{}):xs) = f (x:guards) xs f guards xs = reverse guards ++ xs -listExp :: Bool -> LHsExpr GhcPs -> [Idea]-listExp b (fromParen -> x) =- if null res then concatMap (listExp $ isAppend x) $ children x else [head res]+listExp :: Bool -> Bool -> LHsExpr GhcPs -> [Idea]+listExp overloadedListsOn b (fromParen -> x) =+ if null res+ then concatMap (listExp overloadedListsOn $ isAppend x) $ children x+ else [head res] where res = [suggest name x x2 [r]- | (name, f) <- checks+ | (name, f) <- checks overloadedListsOn , Just (x2, subts, temp) <- [f b x] , let r = Replace Expr (toSS x) subts temp ] @@ -168,12 +175,12 @@ isAppend (view -> App2 op _ _) = varToStr op == "++" isAppend _ = False -checks ::[(String, Bool -> LHsExpr GhcPs -> Maybe (LHsExpr GhcPs, [(String, R.SrcSpan)], String))]-checks = let (*) = (,) in drop1 -- see #174+checks :: Bool -> [(String, Bool -> LHsExpr GhcPs -> Maybe (LHsExpr GhcPs, [(String, R.SrcSpan)], String))]+checks overloadedListsOn = let (*) = (,) in drop1 -- see #174 [ "Use string literal" * useString- , "Use list literal" * useList , "Use :" * useCons ]+ <> ["Use list literal" * useList | not overloadedListsOn ] -- see #114 pchecks :: [(String, LPat GhcPs -> Maybe (LPat GhcPs, [(String, R.SrcSpan)], String))] pchecks = let (*) = (,) in drop1 -- see #174