@@ -35,41 +35,37 @@ import qualified Pipes.Prelude as P
3535-- TODO: remove this when the issue is fixed at Pursuit
3636queryPursuit :: Text -> IO ByteString
3737queryPursuit q = do
38- let qClean = T. dropWhileEnd (== ' .' ) q
39- req' <- parseRequest " http://pursuit.purescript.org/search"
40- let req = req'
41- { queryString= " q=" <> (fromString . T. unpack) qClean
42- , requestHeaders= [(hAccept, " application/json" )]
43- }
44- m <- newManager tlsManagerSettings
45- withHTTP req m $ \ resp ->
46- P. fold (<>) " " identity (responseBody resp)
47-
38+ let qClean = T. dropWhileEnd (== ' .' ) q
39+ req' <- parseRequest " http://pursuit.purescript.org/search"
40+ let req = req'
41+ { queryString= " q=" <> (fromString . T. unpack) qClean
42+ , requestHeaders= [(hAccept, " application/json" )]
43+ }
44+ m <- newManager tlsManagerSettings
45+ withHTTP req m $ \ resp ->
46+ P. fold (<>) " " identity (responseBody resp)
4847
4948handler :: HttpException -> IO [a ]
50- handler StatusCodeException {} = pure []
5149handler _ = pure []
5250
5351searchPursuitForDeclarations :: Text -> IO [PursuitResponse ]
54- searchPursuitForDeclarations query =
55- (do r <- queryPursuit query
56- let results' = decode (fromStrict r) :: Maybe Array
57- case results' of
58- Nothing -> pure []
59- Just results -> pure (mapMaybe (isDeclarationResponse . fromJSON) (toList results))) `E.catch`
60- handler
52+ searchPursuitForDeclarations query = E. handle handler $ do
53+ r <- queryPursuit query
54+ let results' = decode (fromStrict r) :: Maybe Array
55+ case results' of
56+ Nothing -> pure []
57+ Just results -> pure (mapMaybe (isDeclarationResponse . fromJSON) (toList results))
6158 where
6259 isDeclarationResponse (Success a@ DeclarationResponse {}) = Just a
6360 isDeclarationResponse _ = Nothing
6461
6562findPackagesForModuleIdent :: Text -> IO [PursuitResponse ]
66- findPackagesForModuleIdent query =
67- ( do r <- queryPursuit query
68- let results' = decode (fromStrict r) :: Maybe Array
69- case results' of
63+ findPackagesForModuleIdent query = E. handle handler $ do
64+ r <- queryPursuit query
65+ let results' = decode (fromStrict r) :: Maybe Array
66+ case results' of
7067 Nothing -> pure []
71- Just results -> pure (mapMaybe (isModuleResponse . fromJSON) (toList results))) `E.catch`
72- handler
68+ Just results -> pure (mapMaybe (isModuleResponse . fromJSON) (toList results))
7369 where
7470 isModuleResponse (Success a@ ModuleResponse {}) = Just a
7571 isModuleResponse _ = Nothing
0 commit comments