Commit 1e853d8b authored by Alfredo Di Napoli's avatar Alfredo Di Napoli

Build cleanly on GHC 8.10.7 and GHC 9.4.7

parent 66196687
with-compiler: ghc-9.4.7
packages: .
tests: True
source-repository-package
type: git
location: https://github.com/delanoe/data-time-segment.git
tag: 4e3d57d80e9dfe6624c8eeaa8595fc8fe64d8723
packages: .
with-compiler: ghc-8.10.7
source-repository-package
type: git
location: https://github.com/delanoe/data-time-segment.git
tag: 4e3d57d80e9dfe6624c8eeaa8595fc8fe64d8723
......@@ -59,9 +59,9 @@ library
, lens
, mtl
, optparse-applicative
, servant
, servant-client
, servant-client-core
, servant >= 0.18.3 && < 0.20
, servant-client >= 0.18.3 && < 0.20
, servant-client-core >= 0.18.3 && < 0.20
, taggy
, taggy-lens
, text
......@@ -143,6 +143,8 @@ test-suite crawlerPubMed-test
, servant-client-core
, taggy
, taggy-lens
, tasty
, tasty-hunit
, text
, time
default-language: Haskell2010
......@@ -26,7 +26,6 @@ import Network.HTTP.Client (newManager)
import Network.HTTP.Client.TLS (tlsManagerSettings)
import PUBMED.Client
import PUBMED.Parser
import Panic (panic)
import Prelude hiding (takeWhile)
import Servant.Client (runClientM, mkClientEnv, BaseUrl(..), ClientEnv(..), ClientError, Scheme(..))
import qualified Data.ByteString.Lazy as LBS
......@@ -91,7 +90,7 @@ getPage pageNum = do
debugLog $ "[getPage] getting page " <> show pageNum <> ", offset: " <> show offset <> ", perPage: " <> show perPage <> ", query: " <> T.unpack query <> ", apiKey: " <> show apiKey
eDocs <- runSimpleFindPubmedAbstractRequest (Just offset)
case eDocs of
Left err -> panic $ "[getPage] error: " <> show err
Left err -> error $ "[getPage] error: " <> show err
Right docs -> do
_ <- liftIO $ threadDelay 2_000_000 -- two seconds
debugLog $ "[getPage] docs length: " <> show (length docs)
......
......@@ -23,7 +23,6 @@ import qualified Data.ByteString.Lazy as DBL
import qualified Data.Text as T
import qualified Data.Text.Lazy as TL
import qualified Data.Text.Lazy.IO as TLIO
import Panic (panic)
import qualified Text.Read as TR
import qualified Text.Taggy.Lens as TTL
......@@ -40,7 +39,7 @@ parseDocIds txt = map parseId parsed
where
parsed = txt ^.. TTL.html . TTL.allNamed (only "eSearchResult") . namedEl "IdList" . namedEl "Id" . TTL.contents
parseId s = case (TR.readMaybe (T.unpack s) :: Maybe Integer) of
Nothing -> panic $ "Can't read doc id from: " <> (T.unpack s)
Nothing -> error $ "Can't read doc id from: " <> (T.unpack s)
Just cnt -> cnt
parseDocCount :: TL.Text -> Maybe Integer
......@@ -97,7 +96,7 @@ parsePubMed txt = catMaybes $ txt ^.. pubmedArticle . to pubMed
articleId = medline . namedEl "PMID"
pubDate = namedEl "PubmedData" . namedEl "History" . namedEl "PubMedPubDate" . TTL.attributed (ix "PubStatus" . only "pubmed")
pubMedId el = case (TR.readMaybe $ T.unpack $ el ^. TTL.contents) of
Nothing -> panic $ "Cannot parse id: " <> (T.unpack $ el ^. TTL.contents)
Nothing -> error $ "Cannot parse id: " <> (T.unpack $ el ^. TTL.contents)
Just id -> id
pubMedDate el = PubMedDate { pubmedDate_date = jour y m d
, pubmedDate_year = y
......
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