packages feed

hlint 1.9.3 → 1.9.4

raw patch · 10 files changed

+76/−11 lines, 10 filesdep ~hscolourPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: hscolour

API changes (from Hackage documentation)

Files

CHANGES.txt view
@@ -1,5 +1,9 @@ Changelog for HLint +1.9.4+    #81, fixes for GHC 7.9+    #78, add hints for list patterns+    #72, make --color the default on Linux 1.9.3     #73, fix multithreading and exceptions 1.9.2
README.md view
@@ -1,4 +1,4 @@-# HLint [![Build Status](https://travis-ci.org/ndmitchell/hlint.svg)](https://travis-ci.org/ndmitchell/hlint)+# HLint [![Hackage version](https://img.shields.io/hackage/v/hlint.svg?style=flat)](http://hackage.haskell.org/package/hlint) [![Build Status](http://img.shields.io/travis/ndmitchell/hlint.svg?style=flat)](https://travis-ci.org/ndmitchell/hlint)  HLint is a tool for suggesting possible improvements to Haskell code. These suggestions include ideas such as using alternative functions, simplifying code and spotting redundancies. This document is structured as follows: 
hlint.cabal view
@@ -1,7 +1,7 @@ cabal-version:      >= 1.6 build-type:         Simple name:               hlint-version:            1.9.3+version:            1.9.4 license:            BSD3 license-file:       LICENSE category:           Development
src/CmdLine.hs view
@@ -1,7 +1,7 @@ {-# LANGUAGE PatternGuards, RecordWildCards, DeriveDataTypeable #-} {-# OPTIONS_GHC -fno-warn-missing-fields #-} -module CmdLine(Cmd(..), cmdCpp, CppFlags(..), getCmd, cmdExtensions, cmdHintFiles, exitWithHelp, resolveFile) where+module CmdLine(Cmd(..), cmdCpp, CppFlags(..), getCmd, cmdExtensions, cmdHintFiles, cmdUseColour, exitWithHelp, resolveFile) where  import Data.Char import Data.List@@ -10,9 +10,11 @@ import System.Directory import System.Exit import System.FilePath+import System.IO (hIsTerminalDevice, stdout) import Language.Preprocessor.Cpphs import Language.Haskell.Exts.Extension import System.Environment+import System.Info (os)  import Util import Paths_hlint@@ -52,13 +54,27 @@     | Cpphs CpphsOptions -- ^ The @cpphs@ library is used.  +-- | When to colour terminal output.+data ColorMode+    = Never  -- ^ Terminal output will never be coloured.+    | Always -- ^ Terminal output will always be coloured.+    | Auto   -- ^ Terminal output will be coloured if stdout is a terminal.+      deriving (Show, Typeable, Data)+++instance Default ColorMode where+  def = if os == "mingw32"+          then Never+          else Auto++ data Cmd     = CmdMain         {cmdFiles :: [FilePath]    -- ^ which files to run it on, nothing = none given         ,cmdReports :: [FilePath]        -- ^ where to generate reports         ,cmdGivenHints :: [FilePath]     -- ^ which settignsfiles were explicitly given         ,cmdWithHints :: [String]        -- ^ hints that are given on the command line-        ,cmdColor :: Bool                -- ^ color the result+        ,cmdColor :: ColorMode           -- ^ color the result         ,cmdIgnore :: [String]           -- ^ the hints to ignore         ,cmdShowAll :: Bool              -- ^ display all skipped items         ,cmdExtension :: [String]        -- ^ extensions@@ -111,7 +127,7 @@         ,cmdReports = nam "report" &= opt "report.html" &= typFile &= help "Generate a report in HTML"         ,cmdGivenHints = nam "hint" &= typFile &= help "Hint/ignore file to use"         ,cmdWithHints = nam "with" &= typ "HINT" &= help "Extra hints to use"-        ,cmdColor = nam "colour" &= name "color" &= help "Color output (requires ANSI terminal)"+        ,cmdColor = nam "colour" &= name "color" &= opt Always &= typ "always/never/auto" &= help "Color output (requires ANSI terminal; auto means on when stdout is a terminal; by itself, selects always)"         ,cmdIgnore = nam "ignore" &= typ "HINT" &= help "Ignore a particular hint"         ,cmdShowAll = nam "show" &= help "Show all ignored ideas"         ,cmdExtension = nam "extension" &= typ "EXT" &= help "File extensions to search (default hs/lhs)"@@ -124,7 +140,7 @@         ,cmdPath = nam "path" &= help "Directory in which to search for files"         ,cmdCppDefine = nam_ "cpp-define" &= typ "NAME[=VALUE]" &= help "CPP #define"         ,cmdCppInclude = nam_ "cpp-include" &= typDir &= help "CPP include path"-        ,cmdCppFile = nam_ "cpp-file" &= typDir &= help "CPP pre-include file"+        ,cmdCppFile = nam_ "cpp-file" &= typFile &= help "CPP pre-include file"         ,cmdCppSimple = nam_ "cpp-simple" &= help "Use a simple CPP (strip # lines)"         ,cmdCppAnsi = nam_ "cpp-ansi" &= help "Use CPP in ANSI compatibility mode"         ,cmdJson = nam_ "json" &= help "Display hint data as JSON"@@ -168,6 +184,15 @@         ,defines = [(a,drop 1 b) | x <- cmdCppDefine cmd, let (a,b) = break (== '=') x]         }     | otherwise = NoCpp+++-- | Determines whether to use colour or not.+cmdUseColour :: Cmd -> IO Bool+cmdUseColour cmd =+  case cmdColor cmd of+    Auto   -> hIsTerminalDevice stdout+    Never  -> return False+    Always -> return True   "." <\> x = x
src/HLint.hs view
@@ -131,7 +131,8 @@     if cmdJson         then putStrLn . showIdeasJson $ showideas         else do-            showItem <- if cmdColor then showANSI else return show+            usecolour <- cmdUseColour cmd+            showItem <- if usecolour then showANSI else return show             mapM_ (outStrLn . showItem) showideas             if null showideas then                 when (cmdReports /= []) $ outStrLn "Skipping writing reports"
src/HSE/Match.hs view
@@ -26,6 +26,13 @@     view (fromParen -> App _ f x) = App1 f x     view _ = NoApp1 +data PApp_ = NoPApp_ | PApp_ String [Pat_]++instance View Pat_ PApp_ where+    view (fromPParen -> PApp _ x xs) = PApp_ (fromNamed x) xs+    view (fromPParen -> PInfixApp _ lhs op rhs) = PApp_ (fromNamed op) [lhs, rhs]+    view _ = NoPApp_+ data PVar_ = NoPVar_ | PVar_ String  instance View Pat_ PVar_ where@@ -107,6 +114,7 @@ instance Named (Pat S) where     fromNamed (PVar _ x) = fromNamed x     fromNamed (PApp _ x []) = fromNamed x+    fromNamed (PList _ []) = "[]"     fromNamed _ = ""      toNamed x | isCtor x = PApp an (toNamed x) []
src/HSE/Util.hs view
@@ -46,6 +46,13 @@ fromChar :: Exp_ -> Char fromChar (Lit _ (Char _ x _)) = x +isPChar :: Pat_ -> Bool+isPChar (PLit _ Char{}) = True+isPChar _ = False++fromPChar :: Pat_ -> Char+fromPChar (PLit _ (Char _ x _)) = x+ isString :: Exp_ -> Bool isString (Lit _ String{}) = True isString _ = False
src/Hint/List.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE ViewPatterns, PatternGuards #-}+{-# LANGUAGE ViewPatterns, PatternGuards, FlexibleContexts #-}  {-     Find and match:@@ -6,6 +6,8 @@ <TEST> yes = 1:2:[] -- [1,2] yes = ['h','e','l','l','o'] -- "hello"+yes (1:2:[]) = 1 -- [1,2]+yes ['h','e'] = 1 -- "he"  -- [a]++b -> a : b, but only if not in a chain of ++'s yes = [x] ++ xs -- x : xs@@ -33,7 +35,7 @@ listHint _ _ = listDecl  listDecl :: Decl_ -> [Idea]-listDecl x = concatMap (listExp False) (childrenBi x) ++ stringType x+listDecl x = concatMap (listExp False) (childrenBi x) ++ stringType x ++ concatMap listPat (childrenBi x)  -- boolean = are you in a ++ chain listExp :: Bool -> Exp_ -> [Idea]@@ -42,6 +44,9 @@     where         res = [warn name x x2 | (name,f) <- checks, Just x2 <- [f b x]] +listPat :: Pat_ -> [Idea]+listPat x = if null res then concatMap listPat $ children x else [head res]+    where res = [warn name x x2 | (name,f) <- pchecks, Just x2 <- [f x]]  isAppend (view -> App2 op _ _) = op ~= "++" isAppend _ = False@@ -53,6 +58,21 @@          ,"Use :" * useCons          ] +pchecks = let (*) = (,) in+          ["Use string literal pattern" * usePString+          ,"Use list literal pattern" * usePList+          ]+++usePString (PList _ xs) | xs /= [] && all isPChar xs = Just $ PLit an $ String an s (show s)+    where s = map fromPChar xs+usePString _ = Nothing++usePList = fmap (PList an) . f True+    where+        f first x | x ~= "[]" = if first then Nothing else Just []+        f first (view -> PApp_ ":" [a,b]) = (a:) <$> f False b+        f first _ = Nothing  useString b (List _ xs) | xs /= [] && all isChar xs = Just $ Lit an $ String an s (show s)     where s = map fromChar xs
src/Hint/Match.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE PatternGuards, ViewPatterns, RelaxedPolyRec, RecordWildCards #-}+{-# LANGUAGE PatternGuards, ViewPatterns, RelaxedPolyRec, RecordWildCards, FlexibleContexts #-}  {- The matching does a fairly simple unification between the two terms, treating
src/Test/Proof.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE RecordWildCards, PatternGuards #-}+{-# LANGUAGE RecordWildCards, PatternGuards, FlexibleContexts #-}  -- | Check the coverage of the hints given a list of Isabelle theorems module Test.Proof(proof) where