how to structure this project

24 views
Skip to first unread message

r/ Wobben

unread,
Feb 13, 2017, 12:09:37 PM2/13/17
to haskell-servant
Hello,

I'm trying to build a site where the data is pulled out of a external json api.

Now I have 1 question.

Where do I do the fetching and parsing of the json. In the handler or schould I write seperate functions for it that the handler uses ?

Roelof

Alp Mestanogullari

unread,
Feb 13, 2017, 1:22:58 PM2/13/17
to r/ Wobben, haskell-servant
I definitely recommend separate functions. I've always had a harder time working on services where the code for the handlers got long and was doing several things, as opposed to hust delegating the few steps to a few well thought out functions.

--
You received this message because you are subscribed to the Google Groups "haskell-servant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to haskell-servant+unsubscribe@googlegroups.com.
To post to this group, send email to haskell-servant@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/haskell-servant/32834565-980a-459d-864e-02612b8a2f6e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

r/ Wobben

unread,
Feb 13, 2017, 1:37:16 PM2/13/17
to haskell-servant, wobb...@gmail.com
Alp,

Thanks,

So something like this :

type PaintingAPI = "paintings" :> read_all_json() 

where read_all_json is a function which make a request to the api and parse it to a [] ?









Op maandag 13 februari 2017 19:22:58 UTC+1 schreef Alp Mestanogullari:
I definitely recommend separate functions. I've always had a harder time working on services where the code for the handlers got long and was doing several things, as opposed to hust delegating the few steps to a few well thought out functions.
Le 13 févr. 2017 18:09, "r/ Wobben" <wobb...@gmail.com> a écrit :
Hello,

I'm trying to build a site where the data is pulled out of a external json api.

Now I have 1 question.

Where do I do the fetching and parsing of the json. In the handler or schould I write seperate functions for it that the handler uses ?

Roelof

--
You received this message because you are subscribed to the Google Groups "haskell-servant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to haskell-serva...@googlegroups.com.
To post to this group, send email to haskell...@googlegroups.com.

r/ Wobben

unread,
Feb 13, 2017, 1:38:14 PM2/13/17
to haskell-servant, wobb...@gmail.com


Op maandag 13 februari 2017 19:37:16 UTC+1 schreef r/ Wobben:
Alp,

Thanks,

So something like this :

type PaintingAPI = "paintings" :> read_all_json() 

where read_all_json is a function which make a request to the api and parse it to a [] ?

I saw that I have to make 3 seperate calls to the api to get all the data.  
Reply all
Reply to author
Forward
0 new messages