weeder 0.1.3 → 0.1.4
raw patch · 7 files changed
+23/−10 lines, 7 files
Files
- CHANGES.txt +4/−0
- src/CmdLine.hs +2/−0
- src/Hi.hs +1/−1
- src/Main.hs +1/−1
- src/Stack.hs +5/−3
- src/Warning.hs +9/−4
- weeder.cabal +1/−1
CHANGES.txt view
@@ -1,5 +1,9 @@ Changelog for Weeder +0.1.4+ #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 #5, document how to install weeder #8, detect unused imports, even import Foo()
src/CmdLine.hs view
@@ -20,6 +20,7 @@ ,cmdJson :: Bool ,cmdYaml :: Bool ,cmdShowAll :: Bool+ ,cmdDistDir :: Maybe String } deriving (Show, Data, Typeable) getCmd :: IO Cmd@@ -40,6 +41,7 @@ ,cmdJson = nam "json" &= help "Output JSON" ,cmdYaml = nam "yaml" &= help "Output YAML" ,cmdShowAll = nam "show-all" &= help "Show even ignored warnings"+ ,cmdDistDir = nam "dist-dir" &= typDir &= help "Stack dist-dir, defaults to 'stack path --dist-dir'" } &= explicit &= name "weeder" &= verbosity &= summary ("Weeder v" ++ showVersion version ++ ", (C) Neil Mitchell 2017") where
src/Hi.hs view
@@ -118,7 +118,7 @@ ,hiFieldName = Set.fromList [Ident (identModule y) b | Ident "" b <- ys] ,hiSignatures = Map.fromList [(b, Set.singleton y) | Ident _ b <- ys, b /= identName y] }- where y:ys = map parseIdent $ wordsBy (`elem` "|{} ") x+ where y:ys = map parseIdent $ wordsBy (`elem` "{} ") x -- "Language.Haskell.PPHsMode" -> Ident "Language.Haskell" "PPHsMode" parseIdent x
src/Main.hs view
@@ -33,7 +33,7 @@ weedDirectory Cmd{..} dir = do file <- do b <- doesDirectoryExist dir; return $ if b then dir </> "stack.yaml" else dir when cmdBuild $ buildStack file- Stack{..} <- parseStack file+ Stack{..} <- parseStack cmdDistDir file cabals <- forM stackPackages $ \x -> do file <- selectCabalFile $ dir </> x (file,) <$> parseCabal file
src/Stack.hs view
@@ -23,9 +23,11 @@ -- | Note that in addition to parsing the stack.yaml file it also runs @stack@ to -- compute the dist-dir.-parseStack :: FilePath -> IO Stack-parseStack file = do- stackDistDir <- fst . line1 <$> readCreateProcess (proc "stack" ["path","--dist-dir","--stack-yaml=" ++ file]) ""+parseStack :: Maybe FilePath -> FilePath -> IO Stack+parseStack distDir file = do+ stackDistDir <- case distDir of+ Nothing -> fst . line1 <$> readCreateProcess (proc "stack" ["path","--dist-dir","--stack-yaml=" ++ file]) ""+ Just x -> return x stackPackages <- f . decodeYaml <$> readCreateProcess (proc "stack" ["query","locals","--stack-yaml=" ++ file]) "" return Stack{..} where
src/Warning.hs view
@@ -11,6 +11,7 @@ import Cabal import Util+import Control.Monad.Extra import Data.Maybe import Data.List.Extra import Control.Exception@@ -80,15 +81,19 @@ where badYaml want x = error $ "Failed to understand Yaml fragment, expected " ++ want ++ ", got:\n" ++ BS.unpack (Yaml.encode x) + f Null = []+ f (Object mp) | Map.null mp = [] f (Array xs) = concatMap f $ V.toList xs f (Object mp) | [(k,v)] <- Map.toList mp = return $ case v of v | Just (n, rest) <- findName v -> Val (T.unpack k) (T.unpack n) $ f rest- Array xs | Just xs <- mapM fromString $ V.toList xs -> End (T.unpack k) xs+ v | Just xs <- fromStrings v -> End (T.unpack k) xs String x -> End (T.unpack k) [T.unpack x] _ -> badYaml "either a dict with 'name' or a list/single string" $ Object mp- f x = badYaml "either a dict or an array" x- fromString (String x) = Just $ T.unpack x- fromString x = Nothing+ f x = badYaml "either a singleton dict or an array" x++ fromStrings (Array xs) = concatMapM fromStrings $ V.toList xs+ fromStrings (String x) = Just [T.unpack x]+ fromStrings x = Nothing findName (Array xs) | ([name], rest) <- partition (isJust . fromName) $ V.toList xs
weeder.cabal view
@@ -1,7 +1,7 @@ cabal-version: >= 1.18 build-type: Simple name: weeder-version: 0.1.3+version: 0.1.4 license: BSD3 license-file: LICENSE category: Development