hlint 1.6.2 → 1.6.3
raw patch · 4 files changed
+45/−6 lines, 4 files
Files
- data/Test.hs +28/−0
- hlint.cabal +2/−1
- src/HSE/Util.hs +1/−0
- src/Hint/Bracket.hs +14/−5
+ data/Test.hs view
@@ -0,0 +1,28 @@+-- These hints are for test purposes, and are not intended to+-- be used for real.++module HLint.Test where+++error = Prelude.readFile ==> bad++{-+<TEST>+yes = readFile "foo" >>= putStr where res = bad+</TEST>+-}++{-+<TEST>+import Prelude hiding(readFile)+import Data.ByteString.Char8(readFile)+no = readFile "foo" >>= putStr+</TEST>+-}++{-+<TEST>+import Prelude as Prelude2+yes = Prelude2.readFile "foo" >>= putStr where res = bad+</TEST>+-}
hlint.cabal view
@@ -1,7 +1,7 @@ cabal-version: >= 1.6 build-type: Simple name: hlint-version: 1.6.2+version: 1.6.3 license: GPL license-file: LICENSE category: Development@@ -19,6 +19,7 @@ Generalise.hs Dollar.hs HLint.hs+ Test.hs report.html hs-lint.el Extra-Source-Files:
src/HSE/Util.hs view
@@ -49,6 +49,7 @@ fromParen x = x -- is* :: Exp -> Bool+isVar Var{} = True; isVar _ = False isApp App{} = True; isApp _ = False isInfixApp InfixApp{} = True; isInfixApp _ = False isAnyApp x = isApp x || isInfixApp x
src/Hint/Bracket.hs view
@@ -15,6 +15,8 @@ yes = operator foo $ operator where res = operator foo operator no = operator foo $ operator bar yes = (b $ c d) ++ e where res = b (c d) ++ e+yes = (a b $ c d) ++ e where res = a b (c d) ++ e+no = (f . g $ a) ++ e </TEST> -} @@ -40,8 +42,15 @@ testDollar loc x = [idea Error "Redundant $" loc x y | InfixApp a d b <- [x], opExp d ~= "$"- ,let y = App a b, not $ needBracket 0 y a, not $ needBracket 1 y b] ++- [idea Error "Redundant $" loc x y | InfixApp a op b <- [x]- ,(first,Paren (InfixApp c1 d c2)) <- [(True,a),(False,b)], opExp d ~= "$"- ,let c = App c1 (Paren c2),let (a2,b2) = if first then (c,b) else (a,c)- ,let y = InfixApp a2 op b2]+ ,let y = App a b, not $ needBracket 0 y a, not $ needBracket 1 y b]+ +++ [idea Error "Redundant $" loc x (t y)+ |(t, Paren (InfixApp a1 op1 a2)) <- infixes x+ ,opExp op1 ~= "$", isVar a1 || isApp a1 || isParen a1, not $ isAtom a2+ ,let y = App a1 (Paren a2)]+++-- return both sides, and a way to put them together again+infixes :: Exp -> [(Exp -> Exp, Exp)]+infixes (InfixApp a b c) = [(InfixApp a b, c), (\a -> InfixApp a b c, a)]+infixes _ = []