summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeilMitchell <>2017-12-06 21:17:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2017-12-06 21:17:00 (GMT)
commit12fa4fd562cfb50d1efd68ab17596c3abe61b2ef (patch)
treeed67ca14c5fc5be20045cb3360bc049b9e9e44cc
parent5dcbb518570bf6d12ac4407d70467239cd9750ad (diff)
version 0.1.80.1.8
-rw-r--r--CHANGES.txt18
-rw-r--r--src/Cabal.hs12
-rw-r--r--src/Hi.hs3
-rw-r--r--weeder.cabal3
4 files changed, 22 insertions, 14 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index e71a87b..e848e46 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -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
diff --git a/src/Cabal.hs b/src/Cabal.hs
index fd26002..5fc86ff 100644
--- a/src/Cabal.hs
+++ b/src/Cabal.hs
@@ -12,6 +12,7 @@ import System.Directory.Extra
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 @@ parseTop = mconcat . map f . parseHanging . filter (not . isComment) . lines
"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}
diff --git a/src/Hi.hs b/src/Hi.hs
index 235590f..d1f6ebe 100644
--- a/src/Hi.hs
+++ b/src/Hi.hs
@@ -128,7 +128,8 @@ hiParseContents = mconcat . map f . parseHanging2 . S.linesCR
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}
diff --git a/weeder.cabal b/weeder.cabal
index 3abee89..a0ca40b 100644
--- a/weeder.cabal
+++ b/weeder.cabal
@@ -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 @@ executable weeder
Warning
CmdLine
Str
+ Paths_weeder