Skip to content

Commit 2e71575

Browse files
phadejpaf31
authored andcommitted
Support http-client-0.5 (purescript#2284)
1 parent df85f5c commit 2e71575

File tree

3 files changed

+25
-26
lines changed

3 files changed

+25
-26
lines changed

purescript.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ library
117117
fsnotify >= 0.2.1,
118118
Glob >= 0.7 && < 0.8,
119119
haskeline >= 0.7.0.0,
120-
http-client >= 0.4.30 && <0.5,
120+
http-client >= 0.4.30 && <0.6,
121121
http-types -any,
122122
language-javascript == 0.6.*,
123123
lifted-base >= 0.2.3 && < 0.2.4,

src/Language/PureScript/Ide/Pursuit.hs

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -35,41 +35,37 @@ import qualified Pipes.Prelude as P
3535
-- TODO: remove this when the issue is fixed at Pursuit
3636
queryPursuit :: Text -> IO ByteString
3737
queryPursuit 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

4948
handler :: HttpException -> IO [a]
50-
handler StatusCodeException{} = pure []
5149
handler _ = pure []
5250

5351
searchPursuitForDeclarations :: 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

6562
findPackagesForModuleIdent :: 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

stack.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
resolver: lts-6.10
1+
resolver: lts-6.13
22
packages:
33
- '.'
44
extra-deps:
55
- aeson-1.0.0.0
6+
- http-client-0.5.1
7+
- http-client-tls-0.3.0
8+
- pipes-http-1.0.4
69
- semigroups-0.18.2
710
flags:
811
semigroups:

0 commit comments

Comments
 (0)