hlint 1.8.45 → 1.8.46
raw patch · 3 files changed
+21/−2 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- data/Default.hs +18/−1
- hlint.cabal +1/−1
- src/Settings.hs +2/−0
data/Default.hs view
@@ -69,7 +69,12 @@ error = last (sort x) ==> maximum x error = head (sortBy f x) ==> minimumBy f x error = last (sortBy f x) ==> maximumBy f x+error "Avoid reverse" = reverse (sort x) ==> sortBy (flip compare) x+error "Avoid reverse" = reverse (sortBy f x) ==> sortBy (flip f) x+warn = flip (g `on` h) ==> flip g `on` h+warn = (f `on` g) `on` h ==> f `on` (g . h) + -- READ/SHOW error = showsPrec 0 x "" ==> show x@@ -85,15 +90,23 @@ warn "Use map once" = map f (map g x) ==> map (f . g) x warn = x !! 0 ==> head x error = take n (repeat x) ==> replicate n x+error = map f (replicate n x) ==> replicate n (f x)+error = map f (repeat x) ==> repeat (f x) error = head (reverse x) ==> last x error = head (drop n x) ==> x !! n where _ = isNat n error = reverse (tail (reverse x)) ==> init x where note = IncreasesLaziness+error "Avoid reverse" = reverse (reverse x) ==> x where note = IncreasesLaziness -- error = take (length x - 1) x ==> init x -- not true for x == [] error = isPrefixOf (reverse x) (reverse y) ==> isSuffixOf x y error = foldr (++) [] ==> concat error = foldl (++) [] ==> concat where note = IncreasesLaziness error = span (not . p) ==> break p error = break (not . p) ==> span p+error = (takeWhile p x, dropWhile p x) ==> span p x+error = fst (span p x) ==> takeWhile p x+error = snd (span p x) ==> dropWhile p x+error = fst (break p x) ==> takeWhile (not . p) x+error = snd (break p x) ==> dropWhile (not . p) x error = concatMap (++ "\n") ==> unlines error = map id ==> id error = or (map p x) ==> any p x@@ -137,7 +150,6 @@ warn "Use null" = length x >= 1 ==> not (null x) where note = IncreasesLaziness error "Take on a non-positive" = take i x ==> [] where _ = isNegZero i error "Drop on a non-positive" = drop i x ==> x where _ = isNegZero i-error = (takeWhile p l, dropWhile p l) ==> span p l -- FOLDS@@ -279,6 +291,8 @@ error = sequence_ (zipWith f x y) ==> Control.Monad.zipWithM_ f x y error = sequence (replicate n x) ==> Control.Monad.replicateM n x error = sequence_ (replicate n x) ==> Control.Monad.replicateM_ n x+error = mapM f (replicate n x) ==> Control.Monad.replicateM n (f x)+error = mapM_ f (replicate n x) ==> Control.Monad.replicateM_ n (f x) error = mapM f (map g x) ==> mapM (f . g) x error = mapM_ f (map g x) ==> mapM_ (f . g) x error = mapM id ==> sequence@@ -445,9 +459,12 @@ -- COMPLEX +{-+-- these would be a good idea, but we have not yet proven them and they seem to have side conditions error "Use isPrefixOf" = take (length t) s == t ==> t `Data.List.isPrefixOf` s error "Use isPrefixOf" = (take i s == t) ==> _eval_ ((i >= length t) && (t `Data.List.isPrefixOf` s)) where _ = (isList t || isLit t) && isPos i+-} {- -- clever hint, but not actually a good idea
hlint.cabal view
@@ -1,7 +1,7 @@ cabal-version: >= 1.6 build-type: Simple name: hlint-version: 1.8.45+version: 1.8.46 license: BSD3 license-file: LICENSE category: Development
src/Settings.hs view
@@ -28,6 +28,7 @@ getSeverity "warn" = Just Warning getSeverity "warning" = Just Warning getSeverity "error" = Just Error+getSeverity "hint" = Just Error getSeverity _ = Nothing @@ -147,6 +148,7 @@ readSide :: [Decl_] -> (Maybe Exp_, [Note]) readSide = foldl f (Nothing,[]) where f (Nothing,notes) (PatBind _ PWildCard{} Nothing (UnGuardedRhs _ side) Nothing) = (Just side, notes)+ f (Nothing,notes) (PatBind _ (fromNamed -> "side") Nothing (UnGuardedRhs _ side) Nothing) = (Just side, notes) f (side,[]) (PatBind _ (fromNamed -> "note") Nothing (UnGuardedRhs _ note) Nothing) = (side,g note) f _ x = errorOn x "bad side condition"