Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
hal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
crawlers
hal
Commits
2b64e9d8
Commit
2b64e9d8
authored
Mar 06, 2019
by
Mael NICOLAS
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[WIP] Type Response done
parent
94ceed1f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
4 deletions
+29
-4
Main.hs
app/Main.hs
+1
-1
package.yaml
package.yaml
+1
-0
Client.hs
src/HAL/Client.hs
+27
-3
No files found.
app/Main.hs
View file @
2b64e9d8
...
...
@@ -11,7 +11,7 @@ main = do
manager'
<-
newManager
tlsManagerSettings
res
<-
runClientM
(
fl
Nothing
)
(
mkClientEnv
manager'
$
BaseUrl
Https
"api.archives-ouvertes.fr"
443
"
search
"
)
(
mkClientEnv
manager'
$
BaseUrl
Https
"api.archives-ouvertes.fr"
443
""
)
case
res
of
(
Left
err
)
->
print
err
(
Right
val
)
->
print
val
package.yaml
View file @
2b64e9d8
...
...
@@ -27,6 +27,7 @@ dependencies:
-
http-client-tls
-
http-client
-
text
-
containers
library
:
source-dirs
:
src
...
...
src/HAL/Client.hs
View file @
2b64e9d8
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE OverloadedStrings #-}
module
HAL.Client
where
import
Data.Proxy
import
GHC.Generics
import
Servant.API
import
Servant.Client
import
Servant.Client
hiding
(
Response
)
import
Data.Text
import
Data.Map
import
Data.Aeson
type
HALAPI
=
""
:>
QueryParam
"fl"
Text
:>
Get
'[
J
SON
]
[
Text
]
data
Response
=
Response
{
numFound
::
Integer
,
start
::
Int
,
docs
::
[
Doc
]
}
deriving
(
Show
,
Generic
)
instance
FromJSON
Response
where
parseJSON
(
Object
o
)
=
Response
<$>
((
o
.:
"response"
)
>>=
(
.:
"numFound"
))
<*>
((
o
.:
"response"
)
>>=
(
.:
"start"
))
<*>
((
o
.:
"response"
)
>>=
(
.:
"docs"
))
newtype
Doc
=
Doc
(
Map
Text
Value
)
deriving
(
Show
,
Generic
)
instance
FromJSON
Doc
type
HALAPI
=
Search
type
Search
=
"search"
-- fl determine which fields will be returned it can be a list of fields or *
:>
QueryParam
"fl"
Text
:>
Get
'[
J
SON
]
Response
halAPI
::
Proxy
HALAPI
halAPI
=
Proxy
fl
::
Maybe
Text
->
ClientM
[
Text
]
fl
::
Maybe
Text
->
ClientM
Response
fl
=
client
halAPI
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment