-
-
Notifications
You must be signed in to change notification settings - Fork 412
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Display capture hints in router layout #1556
Display capture hints in router layout #1556
Conversation
Interesting. Could this be used as a replacement for https://hackage.haskell.org/package/servant-ekg-0.3.1/docs/src/Servant.Ekg.html#HasEndpoint e.g. to implement prometheus metrics directly in |
bba3f41
to
5b077e9
Compare
It's a step in the right direction, but there's still some work to do before it can replace |
5b077e9
to
5f39372
Compare
Note: due to the discussion above, I removed the dependence to I would appreciate your opinions on whether this dependence could be added back, given the additional feature it brings (being able to tell the type of captured variables) This decision would also affect #1561 |
After giving it some thoughts, I am in favor of re-introducing the
It is possible that carrying |
5f39372
to
baee2be
Compare
I've reinstated the |
This commit introduces a `CaptureHint` type, which is passed as an extra argument to the `CaptureRouter` and `CaptureAllRouter` constructors for the `Router'` type. `CaptureHint` values are then used in `routerLayout`, to display the name and "type" of captured values (single or list), instead of just "<capture>" previously. N.B.: Because the `choice` smart constructor for routers can aggregate `Capture` combinators with different capture hints, the `Capture*Router` constructors actually take a *list* of `CaptureHint`, instead of a single one.
a9531a6
to
38df6ad
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just another minor nitpick on the changelog, otherwise this is good to go for me. 👍
38df6ad
to
a19cb84
Compare
This PR introduces a
CaptureHint
type, which is passed as an extra argument to theCaptureRouter
andCaptureAllRouter
constructors for theRouter'
type.CaptureHint
values are then used inrouterLayout
, to display the name and type of captured values, instead of just<capture>
previously.N.B.:
Because the
choice
smart constructor for routers can aggregateCapture
combinators with different capture hints, theCapture*Router
constructors actually take a list ofCaptureHint
, instead of a single one.This PR also introduces
Spec
tests for therouterLayout
function.Warning:
This change is potentially breaking, because it adds the constraint
Typeable a
to all types that are to be captured. Because all types are typeable since GHC 7.10, this is not as bad as it sounds ; it only break expressions wherea
is quantified in an expression withCapture a
.In those cases, the fix is easy: it suffices to add
Typeable a
to the left-hand side of the quantification constraint.