|
|
|
|
|
by TheSmoke
2133 days ago
|
|
> And even though you told us that it's defining a route, I cannot figure out what it is really doing. It is just not clear. it does nothing. :) that code sample is a description of the API. nothing more. when you're writing programs in a functional way, you describe your computation rather than actually computing it as opposed to imperative languages. imagine summation in math. it is a description rather than computation. you compute the sum according to the description. this API description is exactly the same. the code in the comment is incomplete which makes it harder for you to figure out. where are the handlers? how do we return responses? i believe the rest of the code is actually mapping the API description to actual handlers. server :: Server API
server = getPolls :<|> getPoll :<|> getResults
getPolls = queryDBForPolls `andThen` transFormToJson
getPoll pollId = (queryDBForPoll pollId) `andThen` transformToJson
getResults pollId = (queryDBForResults pollId) `andThen` transformToJson
i agree with the comments and sentiments which say mathematicians learn and write haskell easier than the rest of us but i will tell you a secret: i'm a high school graduate with no degree at all let alone a math / cs one. i'm using haskell happily but it took way much longer time than probably everybody else. it just takes a bit of focused time and will to learn it. |
|