Skip to content

Instantly share code, notes, and snippets.

@dmjio
Created January 18, 2019 19:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmjio/d7408f7e2d182d7c17f07a4aa6d61f6d to your computer and use it in GitHub Desktop.
Save dmjio/d7408f7e2d182d7c17f07a4aa6d61f6d to your computer and use it in GitHub Desktop.
Found:
t = \ a -> (findIndex ((==) a)) ==> (elemIndex a)
Perhaps:
t a = (findIndex ((==) a)) ==> (elemIndex a)
./data/HLint_QuickCheck.hs:119:20: Suggestion: Redundant bracket
Found:
(findIndex ((==) a)) ==> (elemIndex a)
Perhaps:
findIndex ((==) a) ==> (elemIndex a)
./data/HLint_QuickCheck.hs:119:20: Suggestion: Redundant bracket
Found:
(findIndex ((==) a)) ==> (elemIndex a)
Perhaps:
(findIndex ((==) a)) ==> elemIndex a
./data/HLint_QuickCheck.hs:119:21: Warning: Use elemIndex
Found:
findIndex ((==) a)
Perhaps:
elemIndex a
./data/HLint_QuickCheck.hs:119:31: Suggestion: Use section
Found:
((==) a)
Perhaps:
(a ==)
./data/HLint_QuickCheck.hs:121:14: Suggestion: Redundant bracket
Found:
(foldr1 (&&)) ?==> (and)
Perhaps:
foldr1 (&&) ?==> (and)
./data/HLint_QuickCheck.hs:121:15: Warning: Use and
Found:
foldr1 (&&)
Perhaps:
and
Note: removes error on `[]`
./data/HLint_QuickCheck.hs:121:33: Warning: Redundant bracket
Found:
(and)
Perhaps:
and
./data/HLint_QuickCheck.hs:123:9: Warning: Redundant lambda
Found:
t = \ x -> (sqrt x) ==> (x ** 0.5)
Perhaps:
t x = (sqrt x) ==> (x ** 0.5)
./data/HLint_QuickCheck.hs:123:20: Suggestion: Redundant bracket
Found:
(sqrt x) ==> (x ** 0.5)
Perhaps:
sqrt x ==> (x ** 0.5)
./data/HLint_QuickCheck.hs:123:34: Suggestion: Use sqrt
Found:
x ** 0.5
Perhaps:
sqrt x
./data/HLint_QuickCheck.hs:125:9: Warning: Redundant lambda
Found:
t = \ (NegZero i) x -> (take i x) ==> ([])
Perhaps:
t (NegZero i) x = (take i x) ==> ([])
./data/HLint_QuickCheck.hs:125:32: Suggestion: Redundant bracket
Found:
(take i x) ==> ([])
Perhaps:
take i x ==> ([])
./data/HLint_QuickCheck.hs:125:47: Warning: Redundant bracket
Found:
([])
Perhaps:
[]
./data/HLint_QuickCheck.hs:127:9: Warning: Redundant lambda
Found:
t = \ (Compare f) x -> (head (sortBy f x)) ==> (minimumBy f x)
Perhaps:
t (Compare f) x = (head (sortBy f x)) ==> (minimumBy f x)
./data/HLint_QuickCheck.hs:127:32: Suggestion: Redundant bracket
Found:
(head (sortBy f x)) ==> (minimumBy f x)
Perhaps:
head (sortBy f x) ==> (minimumBy f x)
./data/HLint_QuickCheck.hs:127:32: Suggestion: Redundant bracket
Found:
(head (sortBy f x)) ==> (minimumBy f x)
Perhaps:
(head (sortBy f x)) ==> minimumBy f x
./data/HLint_QuickCheck.hs:127:33: Warning: Use minimumBy
Found:
head (sortBy f x)
Perhaps:
minimumBy f x
./data/HLint_QuickCheck.hs:129:9: Warning: Redundant lambda
Found:
t = \ f -> ((f $)) ==> (f)
Perhaps:
t f = ((f $)) ==> (f)
./data/HLint_QuickCheck.hs:129:20: Warning: Redundant bracket
Found:
((f $))
Perhaps:
(f $)
./data/HLint_QuickCheck.hs:129:21: Warning: Redundant $
Found:
(f $)
Perhaps:
f
./data/HLint_QuickCheck.hs:129:32: Warning: Redundant bracket
Found:
(f)
Perhaps:
f
data\\Default.hs:116:1: Warning: Redundant lambda
Found:
_test64 = \ p x -> (and (map p x)) ==> (all p x)
Perhaps:
_test64 p x = (and (map p x)) ==> (all p x)
data\\Default.hs:116:20: Suggestion: Redundant bracket
Found:
(and (map p x)) ==> (all p x)
Perhaps:
and (map p x) ==> (all p x)
data\\Default.hs:116:20: Suggestion: Redundant bracket
Found:
(and (map p x)) ==> (all p x)
Perhaps:
(and (map p x)) ==> all p x
data\\Default.hs:116:21: Warning: Use all
Found:
and (map p x)
Perhaps:
all p x
./data/Test.hs:33:9: Warning: Use concatMap
Found:
concat (map f x)
Perhaps:
concatMap f x
./data/Test.hs:40:8: Warning: Use second
Found:
id Control.Arrow.*** id
Perhaps:
second id
./data/Test.hs:40:8: Warning: Use first
Found:
id Control.Arrow.*** id
Perhaps:
first id
./src/HLint.hs:153:41: Suggestion: Use let
Found:
do files <- cmdHintFiles cmd
settings1 <- readFilesConfig $
map (, Nothing) files ++
[("CommandLine.hs", Just x) | x <- cmdWithHints] ++
[("CommandLine.yaml", Just (enableGroup x)) | x <- cmdWithGroups]
let args2 = [x | SettingArgument x <- settings1]
cmd@CmdMain{..} <- if null args2 then return cmd else
getCmd $ args1 ++ args2
settings2 <- concatMapM
(fmap snd . computeSettings (cmdParseFlags cmd))
cmdFindHints
settings3 <- return
[SettingClassify $ Classify Ignore x "" "" | x <- cmdIgnore]
return (cmd, settings1 ++ settings2 ++ settings3)
Perhaps:
do files <- cmdHintFiles cmd
settings1 <- readFilesConfig $
map (, Nothing) files ++
[("CommandLine.hs", Just x) | x <- cmdWithHints] ++
[("CommandLine.yaml", Just (enableGroup x)) | x <- cmdWithGroups]
let args2 = [x | SettingArgument x <- settings1]
cmd@CmdMain{..} <- if null args2 then return cmd else
getCmd $ args1 ++ args2
settings2 <- concatMapM
(fmap snd . computeSettings (cmdParseFlags cmd))
cmdFindHints
let settings3
= [SettingClassify $ Classify Ignore x "" "" | x <- cmdIgnore]
return (cmd, settings1 ++ settings2 ++ settings3)
./src/Config/Yaml.hs:280:38: Warning: Use const
Found:
\ new old -> new
Perhaps:
const
./src/Test/All.hs:28:86: Suggestion: Use let
Found:
do hasSrc <- doesFileExist "hlint.cabal"
useSrc <- return $ hasSrc && null files
testFiles <- if files /= [] then return files else
do xs <- getDirectoryContents dataDir
return
[dataDir </> x | x <- xs,
takeExtension x `elem` [".hs", ".yml", ".yaml"],
not $ "HLint_" `isPrefixOf` takeBaseName x]
testFiles <- forM testFiles $
\ file ->
do hints <- readFilesConfig [(file, Nothing)]
return
(file,
hints ++
(if takeBaseName file /= "Test" then [] else
map (Builtin . fst) builtinHints))
let wrap msg act = putStr (msg ++ " ") >> act >> putStrLn ""
putStrLn "Testing"
checkCommentedYaml $ dataDir </> "default.yaml"
when useSrc $
wrap "Source annotations" $
do config <- readFilesConfig [(".hlint.yaml", Nothing)]
forM_ builtinHints $
\ (name, _) ->
do progress
testAnnotations
(Builtin name : if name == "Restrict" then config else [])
$ "src/Hint" </> name <.> "hs"
when useSrc $ wrap "Input/outputs" $ testInputOutput main
wrap "Hint names" $
mapM_
(\ x ->
do progress
testNames $ snd x)
testFiles
wrap "Hint annotations" $
forM_ testFiles $
\ (file, h) ->
do progress
testAnnotations h file
when cmdTypeCheck $
wrap "Hint typechecking" $
progress >>
testTypeCheck cmdDataDir cmdTempDir
[h | (file, h) <- testFiles, takeFileName file /= "Test.hs"]
when cmdQuickCheck $
wrap "Hint QuickChecking" $
progress >>
testQuickCheck cmdDataDir cmdTempDir
[h | (file, h) <- testFiles, takeFileName file /= "Test.hs"]
when (null files && not hasSrc) $
putStrLn
"Warning, couldn't find source code, so non-hint tests skipped"
Perhaps:
do hasSrc <- doesFileExist "hlint.cabal"
let useSrc = hasSrc && null files
testFiles <- if files /= [] then return files else
do xs <- getDirectoryContents dataDir
return
[dataDir </> x | x <- xs,
takeExtension x `elem` [".hs", ".yml", ".yaml"],
not $ "HLint_" `isPrefixOf` takeBaseName x]
testFiles <- forM testFiles $
\ file ->
do hints <- readFilesConfig [(file, Nothing)]
return
(file,
hints ++
(if takeBaseName file /= "Test" then [] else
map (Builtin . fst) builtinHints))
let wrap msg act = putStr (msg ++ " ") >> act >> putStrLn ""
putStrLn "Testing"
checkCommentedYaml $ dataDir </> "default.yaml"
when useSrc $
wrap "Source annotations" $
do config <- readFilesConfig [(".hlint.yaml", Nothing)]
forM_ builtinHints $
\ (name, _) ->
do progress
testAnnotations
(Builtin name : if name == "Restrict" then config else [])
$ "src/Hint" </> name <.> "hs"
when useSrc $ wrap "Input/outputs" $ testInputOutput main
wrap "Hint names" $
mapM_
(\ x ->
do progress
testNames $ snd x)
testFiles
wrap "Hint annotations" $
forM_ testFiles $
\ (file, h) ->
do progress
testAnnotations h file
when cmdTypeCheck $
wrap "Hint typechecking" $
progress >>
testTypeCheck cmdDataDir cmdTempDir
[h | (file, h) <- testFiles, takeFileName file /= "Test.hs"]
when cmdQuickCheck $
wrap "Hint QuickChecking" $
progress >>
testQuickCheck cmdDataDir cmdTempDir
[h | (file, h) <- testFiles, takeFileName file /= "Test.hs"]
when (null files && not hasSrc) $
putStrLn
"Warning, couldn't find source code, so non-hint tests skipped"
32 hints
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment