weeder 1.0.5 → 1.0.6
raw patch · 5 files changed
+18/−9 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGES.txt +3/−0
- README.md +1/−1
- src/Stack.hs +10/−4
- src/Util.hs +2/−2
- weeder.cabal +2/−2
CHANGES.txt view
@@ -1,5 +1,8 @@ Changelog for Weeder +1.0.6, released 2018-06-16+ Don't fail with an error if stack setup is necessary+ If you fail to find stack.yaml give a better error message 1.0.5, released 2018-05-05 #39, provide weeder as a library 1.0.4, released 2018-05-02
README.md view
@@ -1,4 +1,4 @@-# Weeder [](https://hackage.haskell.org/package/weeder) [](https://www.stackage.org/package/weeder) [](https://travis-ci.org/ndmitchell/weeder) [](https://ci.appveyor.com/project/ndmitchell/weeder)+# Weeder [](https://hackage.haskell.org/package/weeder) [](https://www.stackage.org/package/weeder) [](https://travis-ci.org/ndmitchell/weeder) [](https://ci.appveyor.com/project/ndmitchell/weeder) Most projects accumulate code over time. Weeder detects unused Haskell exports, allowing dead code to be removed (pulling up the weeds). Weeder piggy-backs off files generated by [`stack`](https://www.haskellstack.org), so first obtain stack, then:
src/Stack.hs view
@@ -1,10 +1,11 @@-{-# LANGUAGE OverloadedStrings, RecordWildCards #-}+{-# LANGUAGE OverloadedStrings, RecordWildCards, ScopedTypeVariables #-} module Stack(Stack(..), findStack, parseStack, buildStack) where import Data.Yaml import Data.List.Extra import Control.Exception+import Control.Monad.Extra import System.Directory.Extra import qualified Data.Text as T import qualified Data.HashMap.Strict as Map@@ -19,9 +20,14 @@ ,stackDistDir :: FilePath } -findStack :: FilePath -> IO String-findStack dir = withCurrentDirectory dir $- fst . line1 <$> cmdStdout "stack" ["path","--config-location","--color=never"]+findStack :: FilePath -> IO FilePath+findStack dir = withCurrentDirectory dir $ do+ let args = ["path","--config-location","--color=never"]+ -- it may do a stack setup, so there may be lots of garbage and then the actual info at the end+ res <- maybe "" (trim . snd) . unsnoc . lines <$> cmdStdout "stack" args+ when (res == "") $+ fail $ "Failed to find stack.yaml file\nCommand: " ++ unwords ("stack":args)+ return res buildStack :: FilePath -> IO () buildStack file = cmd "stack" ["build","--stack-yaml=" ++ file,"--test","--bench","--no-run-tests","--no-run-benchmarks","--color=never"]
src/Util.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE GeneralizedNewtypeDeriving, OverloadedStrings #-}+{-# LANGUAGE GeneralizedNewtypeDeriving, OverloadedStrings, TupleSections #-} module Util( Str,@@ -44,7 +44,7 @@ parseHanging = repeatedly (\(x:xs) -> first (\a -> (x, unindent a)) $ span (maybe True ((== ' ') . fst) . uncons) xs) parseHanging2 :: [Str] -> [(Str, [Str])]-parseHanging2 = repeatedly (\(x:xs) -> first (\a -> (x, a)) $ span (maybe True ((== ' ') . fst) . S.uncons) xs)+parseHanging2 = repeatedly (\(x:xs) -> first (x,) $ span (maybe True ((== ' ') . fst) . S.uncons) xs) unindent :: [String] -> [String] unindent xs = map (drop n) xs
weeder.cabal view
@@ -1,7 +1,7 @@ cabal-version: >= 1.18 build-type: Simple name: weeder-version: 1.0.5+version: 1.0.6 license: BSD3 license-file: LICENSE category: Development@@ -16,7 +16,7 @@ extra-doc-files: README.md CHANGES.txt-tested-with: GHC==8.4.1, GHC==8.2.2, GHC==8.0.2, GHC==7.10.3+tested-with: GHC==8.4.3, GHC==8.2.2, GHC==8.0.2, GHC==7.10.3 source-repository head type: git