hsdev 0.1.2.4 → 0.1.2.5
raw patch · 3 files changed
+17/−15 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- hsdev.cabal +1/−1
- src/HsDev/Commands.hs +3/−3
- src/HsDev/Symbols/Util.hs +13/−11
hsdev.cabal view
@@ -2,7 +2,7 @@ -- see http://haskell.org/cabal/users-guide/ name: hsdev -version: 0.1.2.4 +version: 0.1.2.5 synopsis: Haskell development library and tool with support of autocompletion, symbol info, go to declaration, find references etc. description: Haskell development library and tool with support of autocompletion, symbol info, go to declaration, find references, hayoo search etc.
src/HsDev/Commands.hs view
@@ -68,7 +68,7 @@ restrictCabal cabal, visibleFrom mproj mthis, maybe (const True) inModule qname]) - (findDeclaration db iname) + (newestPackage <$> findDeclaration db iname) where (qname, iname) = splitIdentifier ident @@ -80,7 +80,7 @@ (filter $ checkModule $ allOf [ restrictCabal cabal, inScope mthis qname]) - (findDeclaration db iname) + (newestPackage <$> findDeclaration db iname) where (qname, iname) = splitIdentifier ident @@ -88,7 +88,7 @@ scopeModules :: Database -> Cabal -> FilePath -> ErrorT String IO [Module] scopeModules db cabal file = do (file', mthis, mproj) <- fileCtxMaybe db file - case mproj of + newestPackage <$> case mproj of Nothing -> return $ maybe id (:) mthis $ selectModules (inCabal cabal . moduleId) db Just proj -> let deps' = deps file' proj in return $ concatMap (\p -> selectModules (p . moduleId) db) [
src/HsDev/Symbols/Util.hs view
@@ -7,7 +7,7 @@ allOf, anyOf ) where -import Control.Arrow ((***), (&&&), second) +import Control.Arrow ((***), (&&&), first) import Data.Function (on) import Data.Maybe import Data.List (maximumBy, groupBy, sortBy, partition) @@ -108,21 +108,23 @@ inScope :: Module -> Maybe String -> ModuleId -> Bool inScope this q m = m `imported` qualifier this q --- | Select modules with last package version +-- | Select symbols with last package version newestPackage :: Symbol a => [a] -> [a] newestPackage = uncurry (++) . - (selectNewest *** map fst) . - partition (isJust . snd) . - map (id &&& (moduleNamePackage . symbolModuleLocation)) + ((selectNewest . groupPackages) *** map snd) . + partition (isJust . fst) . + map ((mpackage . symbolModuleLocation) &&& id) where - moduleNamePackage (CabalModule _ (Just p) mname) = Just (mname, p) - moduleNamePackage _ = Nothing - pname = fmap (second packageName) . snd - pver = fmap (packageVersion . snd) . snd - selectNewest :: Symbol a => [(a, Maybe (String, ModulePackage))] -> [a] + mpackage (CabalModule _ (Just p) _) = Just p + mpackage _ = Nothing + pname = fmap packageName . fst + pver = fmap packageVersion . fst + groupPackages :: Symbol a => [(Maybe ModulePackage, a)] -> [(Maybe ModulePackage, [a])] + groupPackages = map (first head . unzip) . groupBy ((==) `on` fst) . sortBy (comparing fst) + selectNewest :: [(Maybe ModulePackage, [a])] -> [a] selectNewest = - map (fst . maximumBy (comparing pver)) . + concatMap (snd . maximumBy (comparing pver)) . groupBy ((==) `on` pname) . sortBy (comparing pname)