avoid unnecessary monad

This commit is contained in:
Joey Hess 2018-12-30 15:59:15 -04:00
parent 84e71dae2e
commit f943138508
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38

View file

@ -129,19 +129,19 @@ knownItems (k, u) = do
return (itemids, u) return (itemids, u)
findDownloads :: URLString -> Annex [ToDownload] findDownloads :: URLString -> Annex [ToDownload]
findDownloads u = go =<< downloadFeed u findDownloads u = go <$> downloadFeed u
where where
go Nothing = pure [] go Nothing = []
go (Just f) = catMaybes <$> mapM (mk f) (feedItems f) go (Just f) = catMaybes $ map (mk f) (feedItems f)
mk f i = case getItemEnclosure i of mk f i = case getItemEnclosure i of
Just (enclosureurl, _, _) -> return $ Just (enclosureurl, _, _) ->
Just $ ToDownload f u i $ Enclosure $ Just $ ToDownload f u i $ Enclosure $
fromFeed enclosureurl fromFeed enclosureurl
Nothing -> case getItemLink i of Nothing -> case getItemLink i of
Just link -> return $ Just $ ToDownload f u i $ Just link -> Just $ ToDownload f u i $
MediaLink $ fromFeed link MediaLink $ fromFeed link
Nothing -> return Nothing Nothing -> Nothing
{- Feeds change, so a feed download cannot be resumed. -} {- Feeds change, so a feed download cannot be resumed. -}
downloadFeed :: URLString -> Annex (Maybe Feed) downloadFeed :: URLString -> Annex (Maybe Feed)