weeder 0.1.7 → 0.1.8
raw patch · 4 files changed
+22/−14 lines, 4 files
Files
- CHANGES.txt +10/−8
- src/Cabal.hs +8/−4
- src/Hi.hs +2/−1
- weeder.cabal +2/−1
CHANGES.txt view
@@ -1,27 +1,29 @@ Changelog for Weeder -0.1.7+0.1.8, released 2017-12-06+ Follow both branches for if/else containing dependencies/modules+0.1.7, released 2017-08-09 #21, detect dependencies that are only required transitively #13, respect the STACK_YAML environment variable #20, add verbosity messages in a lot of places #15, tone down unused import if exporting a cross-package type #11, optimise execution speed (~3x faster)-0.1.6+0.1.6, released 2017-06-18 #10, find files generated by alex/happy-0.1.5+0.1.5, released 2017-06-02 If --yaml and no hints give no output-0.1.4+0.1.4, released 2017-05-27 #9, allow --dist-dir to set the stack dist-dir Deal with operators including | in them Allow arrays of arrays of strings in the .weeder.yaml-0.1.3+0.1.3, released 2017-05-08 #5, document how to install weeder #8, detect unused imports, even import Foo() #7, don't say modules with only instances are always redundant #6, don't give partial pattern matches when reading .weeder.yaml-0.1.2+0.1.2, released 2017-04-29 #3, deal with space-separated hs-source-dirs-0.1.1+0.1.1, released 2017-04-29 #2, use "stack query" rather than parsing stack.yaml-0.1+0.1, released 2017-04-28 Initial version
src/Cabal.hs view
@@ -12,6 +12,7 @@ import System.FilePath import qualified Data.HashMap.Strict as Map import Util+import Data.Char import Data.Maybe import Data.List.Extra import Data.Tuple.Extra@@ -111,14 +112,17 @@ "benchmark" -> mempty{cabalSections=[parseSection (Benchmark name) xs]} _ -> mempty -parseSection typ xs =- mempty{cabalSectionType=typ} <>- mconcat (map f $ parseHanging xs)+parseSection typ xs = mempty{cabalSectionType=typ} <> parse xs where- keyValues (x,xs) = let (x1,x2) = word1 x in (lower x1, filter (not . null) $ map trim $ x2:xs)+ parse = mconcat . map f . parseHanging+ keyValues (x,xs) = let (x1,x2) = word1 x in (lower x1, trimEqual $ filter (not . null) $ x2:xs)+ trimEqual xs = map (drop n) xs+ where n = minimum $ 0 : map (length . takeWhile isSpace) xs listSplit = concatMap (wordsBy (`elem` " ,")) f (keyValues -> (k,vs)) = case k of+ "if" -> parse vs+ "else" -> parse vs "build-depends:" -> mempty{cabalPackages = map (trim . takeWhile (`notElem` "=><")) . splitOn "," $ unwords vs} "hs-source-dirs:" -> mempty{cabalSourceDirs=listSplit vs} "exposed-modules:" -> mempty{cabalExposedModules=listSplit vs}
src/Hi.hs view
@@ -128,7 +128,8 @@ parsePackDep = intercalate "-" . takeWhile (any isAlpha) . wordsBy (== '-') . takeWhile (/= '@') -- "hlint-1.9.41-IPKy9tGF1918X9VRp9DMhp:HSE.All 8002" -> "HSE.All"- parseInterface = drop 1 . snd . breakOn ":" . fst . word1+ -- "HSE.All 8002" -> "HSE.All"+ parseInterface = takeWhileEnd (/= ':') . fst . word1 -- "Apply.applyHintFile" -- "Language.Haskell.PPHsMode{Language.Haskell.PPHsMode caseIndent}
weeder.cabal view
@@ -1,7 +1,7 @@ cabal-version: >= 1.18 build-type: Simple name: weeder-version: 0.1.7+version: 0.1.8 license: BSD3 license-file: LICENSE category: Development@@ -52,3 +52,4 @@ Warning CmdLine Str+ Paths_weeder