packages feed

hlint 1.8.31 → 1.8.32

raw patch · 10 files changed

+36/−19 lines, 10 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

data/Default.hs view
@@ -68,7 +68,7 @@ warn  = x !! 0 ==> head x error = take n (repeat x) ==> replicate n x error = head (reverse x) ==> last x-error = head (drop n x) ==> x !! n+error = head (drop n x) ==> x !! n where note = "if the index is non-negative" error = reverse (tail (reverse x)) ==> init x error = take (length x - 1) x ==> init x error = isPrefixOf (reverse x) (reverse y) ==> isSuffixOf x y@@ -107,6 +107,7 @@ error = findIndices ((==) a) ==> elemIndices a error = findIndices (a ==) ==> elemIndices a error = findIndices (== a) ==> elemIndices a+error = lookup b (zip l [0..]) ==> elemIndex b l  -- FOLDS 
data/Test.hs view
@@ -27,8 +27,8 @@  {-# ANN module "HLint: ignore Test4" #-} {-# ANN annTest2 "HLint: error" #-}-{-# ANN annTest3 "HLint: warn" #-}-{-# ANN type Ann_Test "HLint: ignore" #-}+{-# ANN annTest3 ("HLint: warn" :: String) #-}+{-# ANN type Ann_Test ("HLint: ignore") #-}   error = concat (map f x) ==> Data.List.concatMap f x
hlint.cabal view
@@ -1,7 +1,7 @@ cabal-version:      >= 1.6 build-type:         Simple name:               hlint-version:            1.8.31+version:            1.8.32 -- license is GPL v2 only license:            GPL license-file:       LICENSE
hlint.htm view
@@ -215,7 +215,7 @@ 	<li>After applying one transformation, others that were otherwise suggested may become inappropriate.</li> </ul> <p>-	If someone wanted to write such a feature, trying to work round some of the issues above, it would be happily accepted.+	I am intending to develop such a feature, but the above reasons mean it is likely to take some time. </p>  <h3>Why doesn't the compiler automatically apply the optimisations?</h3>@@ -224,6 +224,12 @@ 	HLint doesn't suggest optimisations, it suggests code improvements - the intention is to make the code simpler, rather than making the code perform faster. The <a href="http://haskell.org/ghc/">GHC compiler</a> automatically applies many of the rules suggested by HLint, so HLint suggestions will rarely improve performance. </p> +<h3>Why doesn't HLint know the fixity for my custom <tt>!@%$</tt> operator?</h3>++<p>+	HLint knows the fixities for all the operators in the base library, but no others. HLint works on a single file at a time, and does not resolve imports, so cannot see fixity declarations from imported modules. You can tell HLint about fixities by putting them in a hint file, or passing them on the command line. For example, pass <tt>"--with=infixr 5 !@%$"</tt>, or put all the fixity declarations in a file and pass <tt>--hint=fixities.hs</tt>. You can also use <tt><a href="#find">--find</a></tt> to automatically produce a list of fixity declarations in a file.+</p>+ <h2 id="customization">Customizing the hints</h2>  <p>@@ -287,16 +293,17 @@ 	The line can be read as replace <tt>concat (map <i>f</i> <i>x</i>)</tt> with <tt>concatMap <i>f</i> <i>x</i></tt>. All single-letter variables are treated as substitution parameters. For examples of more complex hints see the supplied hints file. In general, hints should <i>not</i> be given in point free style, as this reduces the power of the matching. Hints may start with <tt>error</tt> or <tt>warn</tt> to denote how severe they are by default. If you come up with interesting hints, please submit them for inclusion. </p> <p>-	You can search for possible hints to add from a source file with the <tt>--find</tt> flag, for example:+	<a name="find"></a>You can search for possible hints to add from a source file with the <tt>--find</tt> flag, for example: </p> <pre> $ hlint --find=src/Utils.hs -- hints found in src/Util.hs warn = null (intersect a b) ==> disjoint a b warn = dropWhile isSpace ==> ltrim+infixr 5 !: </pre> <p>-	These hints are suitable for inclusion in a custom hint file.+	These hints are suitable for inclusion in a custom hint file. You can also include Haskell fixity declarations in a hint file, and these will also be extracted. If you pass only <tt>--find</tt> flags then the hints will be written out, if you also pass files/folders to check, then the found hints will be automatically used when checking. </p>      </body>
src/CmdLine.hs view
@@ -30,6 +30,7 @@     ,cmdFiles :: Maybe [FilePath]    -- ^ which files to run it on, nothing = none given     ,cmdHintFiles :: [FilePath]      -- ^ which settingsfiles to use     ,cmdGivenHints :: [FilePath]     -- ^ which settignsfiles were explicitly given+    ,cmdWithHints :: [String]        -- ^ hints that are given on the command line     ,cmdReports :: [FilePath]        -- ^ where to generate reports     ,cmdIgnore :: [String]           -- ^ the hints to ignore     ,cmdShowAll :: Bool              -- ^ display all skipped items@@ -48,6 +49,7 @@           | Ver           | Test           | Hints FilePath+          | WithHint String           | Path FilePath           | Report FilePath           | Skip String@@ -71,6 +73,7 @@        ,Option "v" ["version"] (NoArg Ver) "Display version information"        ,Option "r" ["report"] (OptArg (Report . fromMaybe "report.html") "file") "Generate a report in HTML"        ,Option "h" ["hint"] (ReqArg Hints "file") "Hint/ignore file to use"+       ,Option "w" ["with"] (ReqArg WithHint "hint") "Extra hints to use"        ,Option "c" ["color","colour"] (NoArg Color) "Color output (requires ANSI terminal)"        ,Option "i" ["ignore"] (ReqArg Skip "hint") "Ignore a particular hint"        ,Option "s" ["show"] (NoArg ShowAll) "Show all ignored ideas"@@ -136,6 +139,7 @@         ,cmdFiles = files         ,cmdHintFiles = hints         ,cmdGivenHints = givenHints+        ,cmdWithHints = [x | WithHint x <- opt]         ,cmdReports = [x | Report x <- opt]         ,cmdIgnore = [x | Skip x <- opt]         ,cmdShowAll = ShowAll `elem` opt@@ -157,7 +161,7 @@   versionText :: String-versionText = "HLint v" ++ showVersion version ++ ", (C) Neil Mitchell 2006-2011\n"+versionText = "HLint v" ++ showVersion version ++ ", (C) Neil Mitchell 2006-2012\n"   helpText :: String
src/HLint.hs view
@@ -62,7 +62,7 @@ runHints :: Cmd -> ParseFlags -> IO [Suggestion] runHints Cmd{..} flags = do     let outStrLn x = unless cmdQuiet $ putStrLn x-    settings1 <- readSettings cmdDataDir cmdHintFiles+    settings1 <- readSettings cmdDataDir cmdHintFiles cmdWithHints     settings2 <- concatMapM (fmap snd . findSettings flags) cmdFindHints     settings3 <- return [Classify Ignore x ("","") | x <- cmdIgnore]     let settings = settings1 ++ settings2 ++ settings3
src/HSE/Match.hs view
@@ -147,6 +147,7 @@     fromNamed (FunBind _ (name:_)) = fromNamed name     fromNamed (ForImp _ _ _ _ name _) = fromNamed name     fromNamed (ForExp _ _ _ name _) = fromNamed name+    fromNamed (TypeSig _ (name:_) _) = fromNamed name     fromNamed _ = ""      toNamed = error "No toNamed for Decl"
src/Main.hs view
@@ -1,6 +1,6 @@ {- HLint, Haskell source code suggestions-Copyright (C) 2006-2011, Neil Mitchell+Copyright (C) 2006-2012, Neil Mitchell  This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
src/Settings.hs view
@@ -64,23 +64,24 @@  -- Given a list of hint files to start from -- Return the list of settings commands-readSettings :: FilePath -> [FilePath] -> IO [Setting]-readSettings dataDir xs = do-    (builtin,mods) <- fmap unzipEither $ concatMapM (readHints dataDir) xs+readSettings :: FilePath -> [FilePath] -> [String] -> IO [Setting]+readSettings dataDir files hints = do+    (builtin,mods) <- fmap unzipEither $ concatMapM (readHints dataDir) $ map Right files ++ map Left hints     let f m = concatMap (readSetting $ moduleScope m) $ concatMap getEquations $ moduleDecls m     return $ map Builtin builtin ++ concatMap f mods   -- Read a hint file, and all hint files it imports-readHints :: FilePath -> FilePath -> IO [Either String Module_]+readHints :: FilePath -> Either String FilePath -> IO [Either String Module_] readHints dataDir file = do-    y <- parseResult $ parseFile (addInfix parseFlags) file+    let flags = addInfix parseFlags+    y <- parseResult $ either (parseString flags "CommandLine") (parseFile flags) file     ys <- concatM [f $ fromNamed $ importModule i | i <- moduleImports y, importPkg i `elem` [Just "hint", Just "hlint"]]     return $ Right y:ys     where         f x | "HLint.Builtin." `isPrefixOf` x = return [Left $ drop 14 x]-            | "HLint." `isPrefixOf` x = readHints dataDir $ dataDir </> drop 6 x <.> "hs"-            | otherwise = readHints dataDir $ x <.> "hs"+            | "HLint." `isPrefixOf` x = readHints dataDir $ Right $ dataDir </> drop 6 x <.> "hs"+            | otherwise = readHints dataDir $ Right $ x <.> "hs"   readSetting :: Scope -> Decl_ -> [Setting]@@ -115,6 +116,8 @@                     Nothing -> errorOn o "bad classify pragma"                     Just severity -> Just $ Classify severity (ltrim b) ("",name)             where (a,b) = break isSpace $ ltrim $ drop 6 s+        g name (Paren _ x) = g name x+        g name (ExpTypeSig _ x _) = g name x         g _ _ = Nothing readPragma _ = Nothing 
src/Test.hs view
@@ -65,7 +65,7 @@  testHintFile :: FilePath -> FilePath -> IO Result testHintFile dataDir file = do-    hints <- readSettings dataDir [file]+    hints <- readSettings dataDir [file] []     res <- results $ sequence $ nameCheckHints hints : checkAnnotations hints file :                                 [typeCheckHints hints | takeFileName file /= "Test.hs"]     progress@@ -219,10 +219,11 @@         Just got | length got == length want && and (zipWith eq want got) -> return pass                  | otherwise -> do             let trail = replicate (max (length got) (length want)) "<EOF>"-            let (i,g,w):_ = [(i,g,w) | (i,g,w) <- zip3 [1..] (got++trail) (want++trail), not $ eq g w]+            let (i,g,w):_ = [(i,g,w) | (i,g,w) <- zip3 [1..] (got++trail) (want++trail), not $ eq w g]             putStrLn $ unlines                 ["TEST FAILURE IN tests/" ++ pre                 ,"DIFFER ON LINE: " ++ show i                 ,"GOT : " ++ g                 ,"WANT: " ++ w]+            when (null want) $ putStrLn $ unlines $ "FULL OUTPUT FOR GOT:" : got             return failure