4 ms·
I guess it depends on your definition of "really easy". I'm not saying it's the easiest thing in the world, rather it is something that any developer can get if
by weavie 8y ago
I guess it depends on your definition of "really easy". I'm not saying it's the easiest thing in the world, rather it is something that any developer can get if they are willing to bash their head against it for a time (and probably for not as long as they initially fear).
I still don't completely understand what is going on in the route definitions, but I have no problem with setting up a route.
Granted something like this is a gnarly type :
type UserAPI2 = "users" :> "list-all" :> Get '[JSON] [User]
:<|> "list-all" :> "users" :> Get '[JSON] [User]
But really you don't need to think of it as a type, just think of it as setting up a couple of routes. The ':<|>' is the route separator. ':>' represents a '/'. The bit after the final ':>' is what your function needs to return. If you get it wrong the compiler will complain at you.
- platz 8y ago> If you get it wrong the compiler will complain at you. With an incomprehensible error message. Beginners will of course get it wrong. I would rather put beginners on a path that makes them feel like the compiler is helping them, one of the core strengths of Haskell, rather than it just telling them No.
- weavie 8y agoI get your point. I never found Servant a huge problem - it was the framework I started learning Haskell with and I found it was a really good fit. But - I can see others may not get it at first. It is quite different from other frameworks. Also, there are other areas where Servant gets complicated, getting and setting header values, cookies, returning redirects etc.. My original point was don't get bogged down in complicated stuff. If someone just doesn't get Servant, there is always Scotty, which is much more straightforward. Servant is not a reason to feel intimidated by Haskell.