-
Notifications
You must be signed in to change notification settings - Fork 10
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
Can't use different result types inside GitHubKey #13
Comments
What’s the error? This should trivially work, as I just checked the commit history and there hasn’t been any divergence by either library. Also all the examples pass a CI build, so they shouldn’t be able to silently break. |
@donkeybonks I'm talking about the change in |
@artemohanjanyan feel free to open a pull request if you're able to find a way to make them build. We won't have time for a little while to look at it. |
I’m afraid, there is not easy way to fix this. The problem is that the value added to the context essentially has a polymorphic type
I currently worked this around by wrapping the polymorphic type and providing a custom instance: -- do not import `gitHubKey` and `GitHubKey` unqualified
import qualified Servant.GitHub.Webhook (GitHubKey, gitHubKey)
-- HACK
newtype GitHubKey = GitHubKey (forall result. Servant.GitHub.Webhook.GitHubKey result)
gitHubKey :: IO ByteString -> GitHubKey
gitHubKey k = GitHubKey (Servant.GitHub.Webhook.gitHubKey k)
instance HasContextEntry '[GitHubKey] (Servant.GitHub.Webhook.GitHubKey result) where
getContextEntry (GitHubKey x :. _) = x |
This is still a problem. I was pulling my hair out trying to figure out what the problem was until I found this issue. |
Hi @evanrelf I have noticed that if you pin the version of this package to the older version, it is working a lot better (more straightforward code). Nethertheless, a month or so ago I updated the examples to work correctly with latest using the hack as above. |
@evanrelf sorry to hear that this issue got in the way of getting things done! I've thought about this issue some more, and I think there are a number of possible solutions.
I'll need to implement each of these to evaluate what the cost looks like for users. |
@tsani No worries! Unfortunately I'm not familiar enough with why the change was made, why it's problematic for cases like this, or why the solution works. But I think a valid solution is just documenting this case so people don't have trouble in the future. |
I don't have much bandwidth with which I may offer input. My needs are merely to keep the package working github apps. A first glance suggested the PR resulted in a much more complex API than needed - I would take zero offense to if someone replaces it all with better, clearer, awesomer code. If we can use servant to |
I can't compile following example with
servant-github-webhook
>= 0.4:https://github.com/onrock-eng/github-webhooks/tree/master/examples/servant
GitHubKey
is specified without the result type there. I can't figure out a good way to do something similar (use oneGitHubKey
for request bodies of different types) with the latest version ofservant-github-webhook
. I can useData.Aeson.Object
instead of different types, but it's not a pleasant thing to do.The text was updated successfully, but these errors were encountered: