module-management-0.20.2: testdata/split4b-expected/Split4/A.hs
{-# LANGUAGE ScopedTypeVariables #-}
module Split4.A
( getPackages
) where
getPackages :: RepoKey -> Release -> PackageIndex -> IO (Either SomeException [BinaryPackage])
getPackages repo release index =
fileFromURIStrict uri' >>= readControl . either (Left . SomeException) Right
where
readControl :: Either SomeException L.ByteString -> IO (Either SomeException [BinaryPackage])
readControl (Left e) = return (Left e)
readControl (Right s) =
try (case controlFromIndex Uncompressed (show uri') s of
Left e -> return $ Left (SomeException (ErrorCall (show uri' ++ ": " ++ show e)))
Right (B.Control control) -> return (Right $ List.map (toBinaryPackage release index) control)) >>=
return . either (\ (e :: SomeException) -> Left . SomeException . ErrorCall . ((show uri' ++ ":") ++) . show $ e) id
uri' = uri {uriPath = uriPath uri </> packageIndexPath release index}
uri = repoKeyURI repo