packages feed

hlint 1.9.30 → 1.9.31

raw patch · 3 files changed

+19/−11 lines, 3 filesdep ~transformersPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: transformers

API changes (from Hackage documentation)

Files

CHANGES.txt view
@@ -1,5 +1,7 @@ Changelog for HLint +1.9.31+    #222, don't suggest removing ~ if the Strict extension is on 1.9.30     #220, fix incorrect hints of foldr/foldl on a tuple accumulator 1.9.29
hlint.cabal view
@@ -1,7 +1,7 @@ cabal-version:      >= 1.8 build-type:         Simple name:               hlint-version:            1.9.30+version:            1.9.31 license:            BSD3 license-file:       LICENSE category:           Development@@ -46,7 +46,7 @@ library     build-depends:         base == 4.*, process, filepath, directory, containers,-        transformers >= 0.0,+        transformers,         cpphs >= 1.18.1,         cmdargs >= 0.10,         haskell-src-exts >= 1.17 && < 1.18,
src/Hint/Pattern.hs view
@@ -41,6 +41,8 @@ foo = 1 where g (Just !True) = Nothing -- True foo = 1 where Just !True = Nothing foo otherwise = 1 -- _+foo ~x = y -- x+{-# LANGUAGE Strict #-} foo ~x = y </TEST> -} @@ -58,17 +60,19 @@   patternHint :: DeclHint-patternHint _ _ x =+patternHint _ modu x =     concatMap (uncurry hints . swap) (asPattern x) ++     -- PatBind (used in Let and Where) contains lazy-by-default patterns, everything else is strict-    concatMap (patHint False) (universeBi [p | PatBind _ p _ _ <- universe x]) ++-    concatMap (patHint True) (universeBi $ transform noPatBind x) +++    concatMap (patHint strict False) (universeBi [p | PatBind _ p _ _ <- universe x]) +++    concatMap (patHint strict True) (universeBi $ transform noPatBind x) ++     concatMap expHint (universeBi x)     where         noPatBind (PatBind a _ b c) = PatBind a (PWildCard a) b c         noPatBind x = x +        strict = "Strict" `elem` [n | LanguagePragma _ ns <- modulePragmas modu, Ident _ n <- ns] + hints :: (String -> Pattern -> [Refactoring R.SrcSpan] -> Idea) -> Pattern -> [Idea] hints gen (Pattern l rtype pat (UnGuardedRhs d bod) bind)     | length guards > 2 = [gen "Use guards" (Pattern l rtype pat (GuardedRhss d guards) bind) [refactoring]]@@ -145,12 +149,14 @@         alt o@(Alt a pat rhs bind) = [(Pattern a R.Match [pat] rhs bind, \msg (Pattern _ _ [pat] rhs bind) rs -> suggest msg o (Alt a pat rhs bind) [])]  -patHint :: Bool -> Pat_ -> [Idea]-patHint strict o@(PApp _ name args) | length args >= 3 && all isPWildCard args =+-- First Bool is if Strict is a language extension+-- Second Bool is if this pattern in this context is going to be evaluated strictly+patHint :: Bool -> Bool -> Pat_ -> [Idea]+patHint lang strict o@(PApp _ name args) | length args >= 3 && all isPWildCard args =   [suggest "Use record patterns" o (PRec an name []) [Replace R.Pattern (toSS o) [] (prettyPrint $ PRec an name [])] ]-patHint strict o@(PVar _ v) | prettyPrint v == "otherwise" = [warn "Used otherwise as a pattern" o (PWildCard an) []]+patHint lang strict o@(PVar _ v) | prettyPrint v == "otherwise" = [warn "Used otherwise as a pattern" o (PWildCard an) []] -patHint strict o@(PBangPat _ x) | strict, f x = [warn "Redundant bang pattern" o x [r]]+patHint lang strict o@(PBangPat _ x) | strict, f x = [warn "Redundant bang pattern" o x [r]]     where f (PParen _ x) = f x           f (PAsPat _ _ x) = f x           f PLit{} = True@@ -158,14 +164,14 @@           f PInfixApp{} = True           f _ = False           r = Replace R.Pattern (toSS o) [("x", toSS x)] "x"-patHint strict o@(PIrrPat _ x) | f x = [warn "Redundant irrefutable pattern" o x [r]]+patHint False strict o@(PIrrPat _ x) | f x = [warn "Redundant irrefutable pattern" o x [r]]     where f (PParen _ x) = f x           f (PAsPat _ _ x) = f x           f PWildCard{} = True           f PVar{} = True           f _ = False           r = Replace R.Pattern (toSS o) [("x", toSS x)] "x"-patHint _ _ = []+patHint _ _ _ = []   expHint :: Exp_ -> [Idea]