packages feed

hlint 2.0.13 → 2.0.14

raw patch · 3 files changed

+9/−3 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

CHANGES.txt view
@@ -1,5 +1,8 @@ Changelog for HLint +2.0.14+    #376, apply the "use fmap" hint in fewer places+    #421, binaries available for OS X 2.0.13, released 2018-01-12     #376, suggest <$> instead of x <- foo; return $ f x     #401, suggest removing brackets for (f . g) <$> x
hlint.cabal view
@@ -1,7 +1,7 @@ cabal-version:      >= 1.18 build-type:         Simple name:               hlint-version:            2.0.13+version:            2.0.14 license:            BSD3 license-file:       LICENSE category:           Development
src/Hint/Monad.hs view
@@ -24,6 +24,7 @@ yes = do x <- bar; return $ f x -- do f <$> bar yes = do x <- bar; return $ f (g x) -- do f . g <$> bar yes = do x <- bar; return (f $ g x) -- do f . g <$> bar+yes = do x <- bar $ baz; return (f $ g x) no = do x <- bar; return (f x x) {-# LANGUAGE RecursiveDo #-}; no = mdo hook <- mkTrigger pat (act >> rmHook hook) ; return hook yes = do x <- return y; foo x -- @Suggestion do let x = y; foo x@@ -68,7 +69,7 @@         (view -> App2 op x1 (view -> LamConst1 _)) | op ~= ">>=" -> f x1         Do _ xs -> [warn "Redundant return" x (Do an y) rs | Just (y, rs) <- [monadReturn xs]] ++                    [warn "Use join" x (Do an y) rs | Just (y, rs) <- [monadJoin xs ['a'..'z']]] ++-                   [warn "Use fmap" x (Do an y) rs | Just (y, rs) <- [monadFmap xs]] +++                   [warn "Use <$>" x (Do an y) rs | Just (y, rs) <- [monadFmap xs]] ++                    [warn "Redundant do" x y [Replace Expr (toSS x) [("y", toSS y)] "y"]                         | [Qualifier _ y] <- [xs], not $ doOperator parent y] ++                    [suggest "Use let" x (Do an y) rs | Just (y, rs) <- [monadLet xs]] ++@@ -106,10 +107,12 @@                                           go (InfixApp _ f (isDol -> True) x) = first (f:) $ go x                                           go x = ([], x)                                       in go -> (ret:f:fs, view -> Var_ v))):g@(Generator _ (view -> PVar_ u) x):rest)-    | ret ~= "return", u == v, v `notElem` vars (f:fs)+    | ret ~= "return", notDol x, u == v, null rest, v `notElem` vars (f:fs)     = Just (reverse (Qualifier an (InfixApp an (foldl' (flip (InfixApp an) (toNamed ".")) f fs) (toNamed "<$>") x):rest),             [Replace Stmt (toSS g) (("x", toSS x):zip vs (toSS <$> f:fs)) (intercalate " . " vs ++ " <$> x"), Delete Stmt (toSS q)])   where vs = ('f':) . show <$> [0..]+        notDol (InfixApp _ _ op _) = not $ isDol op+        notDol _ = True monadFmap _ = Nothing  monadReturn :: [Stmt S] -> Maybe ([Stmt S], [Refactoring R.SrcSpan])