|
|
|
|
|
by TheSmoke
2133 days ago
|
|
it might look weird to the foreign eyes but essentially this is just a typed api with 3 routes. /polls returns an array of Poll.
/polls/:question_id returns a Poll.
/polls/:question_id/results returns a PollResults. the thing you call a mess is the combination of type level operators which helps you describe your API which is the essence of functional programming. |
|
It is telling that this is "just a typed api with 3 routes". Somebody who haven't learned all the specific bits of Haskell (or, for that matter, specific bits of this program that may be overloading strange operators to define routes) won't even start to guess that it's defining routes. They can guess it is defining an API, thanks to the words used at the beginning of the snippet. 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.
So, yes, it looks like a mess for the foreign eye. I have no doubt it looks straightforward as soon as you learn Haskell and practice a bit.
Mainstream languages also look gibberish for people who haven't learned programming though. That's also something that we have to humbly keep in mind while, as foreigners who practice other programming languages, we discuss the syntax of Haskell.