Remove uses of servant-generic in public Galley API#2022
Conversation
41e7234 to
4c29473
Compare
fisx
left a comment
There was a problem hiding this comment.
No objections from me, just a few questions. Let's see what other people think! Maybe wait for another approval or two?
There was a problem hiding this comment.
I like the more tree-shaped structure! Much nicer than the comments over sections of a huge record.
There was a problem hiding this comment.
wasn't the named record fields thing coincidental, and the true purpose of using records was to have better error messages?
what do the error messages look like with named routes?
There was a problem hiding this comment.
The Named stuff compensates for the fact that handlers have to be matched up with their types in order. If you swap two similar unnamed handlers by mistake, you won't get an error if their types are the same. By using Named types and handlers, we get a name mismatch error (which actually looks reasonably nice). I don't mind getting rid of the Named trick altogether, if people think it's not necessary.
Errors messages are in general horrible. GHC unhelpfully spews out the whole API type multiple times in the output, forcing you to use some kind of pager to be able to see the top of the error message. It wasn't much better before, but I have to admit this change did not improve things in this regard.
For example, if you forget a handler, GHC points you to the the last one, instead of the spot where the handler is missing. If you misplace a handler, it just says that some types don't match, with no indication to where the problem is.
There are probably ways to improve this, but I'm in general a bit sceptical about meddling with error messages, as it can result in very confusing messages sometimes (e.g. in servant's Union stuff).
There was a problem hiding this comment.
ok, thanks for the background. now i think i prefer the 'Named' thing, but only slightly.
no further questions! once we've had a few more eyes i'm happy with these changes.
0a42eb8 to
2155211
Compare
The generic mechanism in Servant for defining API types is cumbersome and slow to compile. This commit replaces the API record for the public Galley API with a tree explicitly built using the `:<|>` operator. To make up for the lack of record labels, it also introduces a `Named` combinator for servant API types, which can be used to tag an endpoint with a name (usually a symbol). The name must match the one with which the handler is wrapped.
2155211 to
04d72de
Compare
The generic mechanism in Servant for defining API types is cumbersome and slow to compile. This commit replaces the API record for the public Galley API with a tree explicitly built using the
:<|>operator.To make up for the lack of record labels, it also introduces a
Namedcombinator for servant API types, which can be used to tag an endpoint with a name (usually a symbol). The name must match the one with which the handler is wrapped.Compile times are indeed better with this change, but unfortunately not by much.
Checklist
changelog.d.