weeder 0.1.10 → 0.1.11
raw patch · 5 files changed
+21/−9 lines, 5 files
Files
- CHANGES.txt +3/−1
- src/Cabal.hs +3/−3
- src/Hi.hs +3/−3
- src/Util.hs +11/−1
- weeder.cabal +1/−1
CHANGES.txt view
@@ -1,6 +1,8 @@ Changelog for Weeder -0.1.10+0.1.11, released 2017-12-29+ #29, deal with case-insensitive FilePath on Windows+0.1.10, released 2017-12-28 Make --verbose print out the directory when running commands Don't report semigroups as unused on any platforms 0.1.9, released 2017-12-07
src/Cabal.hs view
@@ -29,7 +29,7 @@ _ -> fail $ "Didn't find exactly 1 cabal file in " ++ dir -- | Return the (exposed Hi files, internal Hi files, not found)-selectHiFiles :: FilePath -> Map.HashMap FilePath a -> CabalSection -> ([a], [a], [ModuleName])+selectHiFiles :: FilePath -> Map.HashMap FilePathEq a -> CabalSection -> ([a], [a], [ModuleName]) selectHiFiles distDir his sect@CabalSection{..} = (external, internal, bad1++bad2) where (bad1, external) = partitionEithers $@@ -38,11 +38,11 @@ (bad2, internal) = partitionEithers [findHi his sect $ Right x | x <- filter (not . isPathsModule) cabalOtherModules] - findHi :: Map.HashMap FilePath a -> CabalSection -> Either FilePath ModuleName -> Either ModuleName a+ findHi :: Map.HashMap FilePathEq a -> CabalSection -> Either FilePath ModuleName -> Either ModuleName a findHi his cabal@CabalSection{..} name = maybe (Left mname) Right $ firstJust (`Map.lookup` his) poss where mname = either takeFileName id name- poss = [ normalise $ joinPath (root : x : either (return . dropExtension) (splitOn ".") name) <.> "dump-hi"+ poss = [ filePathEq $ joinPath (root : x : either (return . dropExtension) (splitOn ".") name) <.> "dump-hi" | extra <- [".",distDir] , root <- ["build" </> extra </> x </> (x ++ "-tmp") | Just x <- [cabalSectionTypeName cabalSectionType]] ++ ["build", "build" </> distDir </> "build"]
src/Hi.hs view
@@ -74,9 +74,9 @@ mappend = (<>) -- | Don't expose that we're just using the filename internally-newtype HiKey = HiKey FilePath deriving (Eq,Ord,Hashable)+newtype HiKey = HiKey FilePathEq deriving (Eq,Ord,Hashable) -hiParseDirectory :: FilePath -> IO (Map.HashMap FilePath HiKey, Map.HashMap HiKey Hi)+hiParseDirectory :: FilePath -> IO (Map.HashMap FilePathEq HiKey, Map.HashMap HiKey Hi) hiParseDirectory dir = do whenLoud $ putStrLn $ "Reading hi directory " ++ dir files <- filter ((==) ".dump-hi" . takeExtension) <$> listFilesRecursive dir@@ -92,7 +92,7 @@ evaluate $ rnf res return (len, res) whenLoud $ putStrLn $ S.showLength len ++ " bytes in " ++ showDuration time- return (name, res)+ return (filePathEq name, res) -- here we try and dedupe any identical Hi modules let keys = Map.fromList $ map (second HiKey . swap) his mp1 <- evaluate $ Map.fromList $ map (second (keys Map.!)) his
src/Util.hs view
@@ -1,7 +1,8 @@-{-# LANGUAGE GADTs, OverloadedStrings #-}+{-# LANGUAGE GeneralizedNewtypeDeriving, OverloadedStrings #-} module Util( Str,+ FilePathEq, filePathEq, PackageName, ModuleName, IdentName, parseHanging, parseHanging2, unindent2,@@ -19,7 +20,9 @@ import Data.List.Extra import Data.Tuple.Extra import System.Process+import System.FilePath import System.Directory+import System.Info.Extra import System.Console.CmdArgs.Verbosity import Str(Str) import qualified Str as S@@ -68,6 +71,13 @@ isHaskellCtor [] = False isHaskellCtor (x:xs) = isUpper x || x == ':' +-- | Normal 'FilePath' has 'Eq' but it allows non-normalised paths+-- and on Windows is case-sensitive even when the underlying file system isn't.+newtype FilePathEq = FilePathEq FilePath+ deriving (Hashable,Eq,Ord,Show)++filePathEq :: FilePath -> FilePathEq+filePathEq = FilePathEq . (if isWindows then lower else id) . normalise -- | Given a list of mappings, and an initial set, find which items can be reached reachable :: (Eq k, Hashable k) => (k -> [k]) -> [k] -> Set.HashSet k
weeder.cabal view
@@ -1,7 +1,7 @@ cabal-version: >= 1.18 build-type: Simple name: weeder-version: 0.1.10+version: 0.1.11 license: BSD3 license-file: LICENSE category: Development