Show stray cabals, fixes #45
This commit is contained in:
parent
2641d50c21
commit
e24c9a3ffe
30
lib/GHCup.hs
30
lib/GHCup.hs
@ -506,6 +506,9 @@ listVersions av lt criteria pfreq = do
|
|||||||
GHC -> do
|
GHC -> do
|
||||||
slr <- strayGHCs avTools
|
slr <- strayGHCs avTools
|
||||||
pure $ (sort (slr ++ lr))
|
pure $ (sort (slr ++ lr))
|
||||||
|
Cabal -> do
|
||||||
|
slr <- strayCabals avTools
|
||||||
|
pure $ (sort (slr ++ lr))
|
||||||
_ -> pure lr
|
_ -> pure lr
|
||||||
Nothing -> do
|
Nothing -> do
|
||||||
ghcvers <- listVersions av (Just GHC) criteria pfreq
|
ghcvers <- listVersions av (Just GHC) criteria pfreq
|
||||||
@ -554,6 +557,33 @@ listVersions av lt criteria pfreq = do
|
|||||||
[i|Could not parse version of stray directory #{toFilePath e}|]
|
[i|Could not parse version of stray directory #{toFilePath e}|]
|
||||||
pure Nothing
|
pure Nothing
|
||||||
|
|
||||||
|
strayCabals :: (MonadReader Settings m, MonadCatch m, MonadThrow m, MonadLogger m, MonadIO m)
|
||||||
|
=> Map.Map Version [Tag]
|
||||||
|
-> m [ListResult]
|
||||||
|
strayCabals avTools = do
|
||||||
|
cabals <- getInstalledCabals
|
||||||
|
fmap catMaybes $ forM cabals $ \case
|
||||||
|
Right ver ->
|
||||||
|
case Map.lookup ver avTools of
|
||||||
|
Just _ -> pure Nothing
|
||||||
|
Nothing -> do
|
||||||
|
lSet <- fmap (maybe False (== ver)) $ cabalSet
|
||||||
|
pure $ Just $ ListResult
|
||||||
|
{ lTool = Cabal
|
||||||
|
, lVer = ver
|
||||||
|
, lCross = Nothing
|
||||||
|
, lTag = []
|
||||||
|
, lInstalled = True
|
||||||
|
, lStray = maybe True (const False) (Map.lookup ver avTools)
|
||||||
|
, lNoBindist = False
|
||||||
|
, fromSrc = False -- actually, we don't know :>
|
||||||
|
, ..
|
||||||
|
}
|
||||||
|
Left e -> do
|
||||||
|
$(logWarn)
|
||||||
|
[i|Could not parse version of stray directory #{toFilePath e}|]
|
||||||
|
pure Nothing
|
||||||
|
|
||||||
-- NOTE: this are not cross ones, because no bindists
|
-- NOTE: this are not cross ones, because no bindists
|
||||||
toListResult :: (MonadReader Settings m, MonadIO m, MonadCatch m) => Tool -> (Version, [Tag]) -> m ListResult
|
toListResult :: (MonadReader Settings m, MonadIO m, MonadCatch m) => Tool -> (Version, [Tag]) -> m ListResult
|
||||||
toListResult t (v, tags) = case t of
|
toListResult t (v, tags) = case t of
|
||||||
|
Loading…
Reference in New Issue
Block a user