Commit eb130c71 authored by Alfredo Di Napoli's avatar Alfredo Di Napoli

Correctly terminate results function

This commit fixes a bug in the 'results' function. This function
was not using the 'Ax.exhausted' function which checks if we are
done fetching results from Arxiv. As a result the generated 'Conduit'
would get stuck demanding results, resulting in the caller never
making progress.
parent 2d7e5753
......@@ -94,7 +94,7 @@ searchAxv' q =
case getResponseStatus rsp of
(Status 200 _) -> case getSoup (getResponseBody rsp) of
[] -> pure (0, C.yieldMany [])
soups@(s:_) -> pure (Ax.totalResults soups, results q soups)
soups -> pure (Ax.totalResults soups, results q soups)
st -> error $ "Error:" ++ show st
searchAxv :: (Monad m, C.MonadIO m) => Ax.Query -> C.ConduitT () Result m ()
......@@ -133,7 +133,9 @@ toSoup = C.awaitForever (C.yield . parseTags . B.unpack)
results :: (Monad m, C.MonadIO m) =>
Ax.Query -> [Soup] -> C.ConduitT () Result m ()
results q sp = do
Ax.forEachEntryM sp (C.yield . mkResult)
if Ax.exhausted sp
then pure ()
else do Ax.forEachEntryM sp (C.yield . mkResult)
searchAxv (Ax.nextPage q)
----------------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment