hlint 1.8.49 → 1.8.50
raw patch · 7 files changed
+79/−17 lines, 7 filesdep ~cpphsdep ~hscolourdep ~transformersPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: cpphs, hscolour, transformers, uniplate
API changes (from Hackage documentation)
Files
- data/Default.hs +3/−3
- hlint.cabal +6/−6
- src/HSE/Util.hs +8/−1
- src/Hint/Extensions.hs +55/−1
- src/Hint/ListRec.hs +1/−1
- src/Hint/Match.hs +4/−1
- src/Util.hs +2/−4
data/Default.hs view
@@ -181,8 +181,8 @@ error = (\x -> x) ==> id error = (\x y -> x) ==> const-error = (\(x,y) -> y) ==> snd where _ = notIn x y-error = (\(x,y) -> x) ==> fst where _ = notIn y x+error = (\(x,y) -> y) ==> snd+error = (\(x,y) -> x) ==> fst warn "Use curry" = (\x y -> f (x,y)) ==> curry f where _ = notIn [x,y] f warn "Use uncurry" = (\(x,y) -> f x y) ==> uncurry f where _ = notIn [x,y] f; note = IncreasesLaziness error "Redundant $" = (($) . f) ==> f@@ -539,7 +539,6 @@ no = [Left x | Left x <- xs] yes = Map.union a b -- a `Map.union` b when p s = if p then s else return ()-yes = x ^^ 18 -- x ** 18 no = x ^^ 18.5 instance Arrow (->) where first f = f *** id yes = fromInteger 12 -- 12@@ -564,6 +563,7 @@ main = take (-y) x main = take 4 x main = let (first, rest) = (takeWhile p l, dropWhile p l) in rest -- span p l+main = map $ \ d -> ([| $d |], [| $d |]) import Prelude \ yes = flip mapM -- Control.Monad.forM
hlint.cabal view
@@ -1,7 +1,7 @@ cabal-version: >= 1.6 build-type: Simple name: hlint-version: 1.8.49+version: 1.8.50 license: BSD3 license-file: LICENSE category: Development@@ -38,11 +38,11 @@ library build-depends: base == 4.*, process, filepath, directory, containers,- transformers >= 0.0 && < 0.4,- hscolour >= 1.17 && < 1.21,- cpphs >= 1.11 && < 1.17,- haskell-src-exts >= 1.11 && < 1.14,- uniplate >= 1.5 && < 1.7+ transformers >= 0.0,+ hscolour >= 1.17,+ cpphs >= 1.11,+ haskell-src-exts >= 1.11,+ uniplate >= 1.5 hs-source-dirs: src exposed-modules:
src/HSE/Util.hs view
@@ -67,6 +67,9 @@ fromTyParen (TyParen _ x) = fromTyParen x fromTyParen x = x +fromDeriving :: Deriving s -> [InstHead s]+fromDeriving (Deriving _ x) = x+ -- is* :: Exp_ -> Bool -- is* :: Decl_ -> Bool isVar Var{} = True; isVar _ = False@@ -93,6 +96,7 @@ isPatTypeSig PatTypeSig{} = True; isPatTypeSig _ = False isQuasiQuote QuasiQuote{} = True; isQuasiQuote _ = False isSpliceDecl SpliceDecl{} = True; isSpliceDecl _ = False+isNewType NewType{} = True; isNewType _ = False isSection LeftSection{} = True isSection RightSection{} = True@@ -252,7 +256,10 @@ vars :: Biplate a Exp_ => a -> [String]-vars xs = [prettyPrint x | Var _ (UnQual _ x) <- universeS xs]+vars = concatMap f . universeS+ where f (Var _ (UnQual _ x)) = [prettyPrint x]+ f (SpliceExp _ (IdSplice _ x)) = [x]+ f _ = [] pvars :: Biplate a Pat_ => a -> [String] pvars xs = [prettyPrint x | PVar _ x <- universeS xs]
src/Hint/Extensions.hs view
@@ -31,6 +31,24 @@ record = 1 -- {-# LANGUAGE TemplateHaskell #-} \ foo+{-# LANGUAGE GeneralizedNewtypeDeriving, DeriveDataTypeable #-} \+record = 1 --+{-# LANGUAGE GeneralizedNewtypeDeriving, DeriveDataTypeable #-} \+newtype Foo = Foo Int deriving Data -- {-# LANGUAGE DeriveDataTypeable #-}+{-# LANGUAGE GeneralizedNewtypeDeriving, DeriveDataTypeable #-} \+data Foo = Foo Int deriving Data -- {-# LANGUAGE DeriveDataTypeable #-}+{-# LANGUAGE GeneralizedNewtypeDeriving, DeriveDataTypeable #-} \+newtype Foo = Foo Int deriving Class -- {-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE GeneralizedNewtypeDeriving, DeriveDataTypeable #-} \+data Foo = Foo Int deriving Class --+{-# LANGUAGE DeriveFunctor #-} \+data Foo = Foo Int deriving Functor+{-# LANGUAGE DeriveFunctor #-} \+newtype Foo = Foo Int deriving Functor --+{-# LANGUAGE DeriveFunctor, GeneralizedNewtypeDeriving, StandaloneDeriving #-} \+deriving instance Functor Bar+{-# LANGUAGE DeriveFunctor, GeneralizedNewtypeDeriving, StandaloneDeriving #-} \+deriving instance Show Bar -- {-# LANGUAGE StandaloneDeriving #-} </TEST> -} @@ -41,6 +59,7 @@ import Data.Maybe import Data.List import Util+import Control.Arrow extensionsHint :: ModuHint@@ -98,6 +117,13 @@ used PackageImports = hasS (isJust . importPkg) used QuasiQuotes = hasS isQuasiQuote used ViewPatterns = hasS isPViewPat+used DeriveDataTypeable = hasDerive True ["Data","Typeable"]+used (UnknownExtension "DeriveGeneric") = hasDerive False ["Generic","Generic1"]+used (UnknownExtension "DeriveFunctor") = hasDerive False ["Functor"]+used (UnknownExtension "DeriveFoldable") = hasDerive False ["Foldable"]+used (UnknownExtension "DeriveTraversable") = hasDerive False ["Traversable"]+used GeneralizedNewtypeDeriving = not . null . filter (`notElem` special) . fst . derives+ where special = ["Read","Show","Data","Typeable"] -- these classes cannot use generalised deriving used Arrows = hasS f where f Proc{} = True f LeftArrApp{} = True@@ -109,8 +135,36 @@ where f QualStmt{} = False f _ = True -used _ = const True+-- for forwards compatibility, if things ever get added to the extension enumeration+used (UnknownExtension _) = const True+used x = used $ UnknownExtension $ show x ++hasDerive :: Bool -> [String] -> Module_ -> Bool+hasDerive nt want m = not $ null $ intersect want $ if nt then new ++ dat else dat+ where (new,dat) = derives m+++-- | What is derived on newtype, and on data type+-- 'deriving' declarations may be on either, so we approximate+derives :: Module_ -> ([String],[String])+derives = (concat *** concat) . unzip . map f . childrenBi+ where+ f :: Decl_ -> ([String], [String])+ f (DataDecl _ dn _ _ _ ds) = g dn ds+ f (GDataDecl _ dn _ _ _ _ ds) = g dn ds+ f (DataInsDecl _ dn _ _ ds) = g dn ds+ f (GDataInsDecl _ dn _ _ _ ds) = g dn ds+ f (DerivDecl _ _ hd) = (xs, xs) -- don't know whether this was on newtype or not+ where xs = [h hd]+ f _ = ([], [])++ g dn ds = if isNewType dn then (xs,[]) else ([],xs)+ where xs = maybe [] (map h . fromDeriving) ds++ h (IHead _ a _) = prettyPrint $ unqual a+ h (IHInfix _ _ a _) = prettyPrint $ unqual a+ h (IHParen _ a) = h a un = undefined
src/Hint/ListRec.hs view
@@ -158,7 +158,7 @@ findPat :: [Pat_] -> Maybe ([String], Int, BList) findPat ps = do ps <- mapM readPat ps- [i] <- return $ findIndices isRight ps+ [i] <- return $ findIndices isRight_ ps let (left,[right]) = partitionEithers ps return (left, i, right)
src/Hint/Match.hs view
@@ -179,7 +179,10 @@ | 'i':'s':typ <- fromNamed cond = isType typ y f (App _ (App _ cond (sub -> x)) (sub -> y))- | cond ~= "notIn" = and [x `notElem` universe y | x <- list x, y <- list y]+ | cond ~= "notIn" = and [ case x of+ Var _ (UnQual _ x) -> prettyPrint x `notElem` vars y+ _ -> x `notElem` universe y+ | x <- list x, y <- list y] | cond ~= "notEq" = x /= y f x | x ~= "notTypeSafe" = True f x = error $ "Hint.Match.checkSide, unknown side condition: " ++ prettyPrint x
src/Util.hs view
@@ -70,10 +70,8 @@ headDef x [] = x headDef x (y:ys) = y -#if !MIN_VERSION_base(4,7,0)-isLeft Left{} = True; isLeft _ = False-isRight = not . isLeft-#endif+isLeft_ Left{} = True; isLeft_ _ = False+isRight_ = not . isLeft_ unzipEither :: [Either a b] -> ([a], [b]) unzipEither (x:xs) = case x of