Skip to content
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

WebSocket has fewer instances than Raw #2

Open
3noch opened this issue Oct 3, 2017 · 5 comments
Open

WebSocket has fewer instances than Raw #2

3noch opened this issue Oct 3, 2017 · 5 comments

Comments

@3noch
Copy link

3noch commented Oct 3, 2017

I don't understand the internals yet but it's clear that the WebSocket type is lacking some instances that Raw has. When trying to wrap servant-auth's Auth combinator around Raw, things work fine. But if I wrap it around WebSocket I get a No instance for (HasServer (AddSetCookieApi (AddSetCookieApi WebSocket)) '[CookieSettings, JWTSettings]).

@3noch 3noch changed the title Has fewer instances than Raw WebSocket has fewer instances than Raw Oct 3, 2017
@moesenle
Copy link
Owner

moesenle commented Oct 7, 2017

Thanks for the report! I'm also still pretty inexperienced with the internals of servant. This library was more like an early experiment. But I'll look into it as soon as I have time.

@3noch
Copy link
Author

3noch commented Oct 10, 2017

Actually I might be wrong about this. It may be that servant-auth has specific handling of Raw. I'll need to see if it is extensible!

@SamProtas
Copy link

So I ran into this issue as well (servant-auth authenticated Websockets not type-checking) and here's what I came up with:

type instance AddSetCookieApi WebSocket = WebSocket

instance AddSetCookies ('S n) (m ()) (m ()) where
  addSetCookies _ a = a

I'm currently using:

servant-auth 0.3.1.0
servant-auth-server 0.3.2.0
servant-websockets 1.1.0

At this point I think this needs to stay an orphan as I doubt either servant-auth or servant-websockets will aquire the other as a dependency.

Assuming I'm understanding the problem (and solution) correctly, it may be beneficial to change the associated types for HasServer Websocket m etc. to something like Connection -> m WebsocketNoResponse instead of Connection -> m (). This way, the orphan instance above won't clobber someone actually trying to return () somewhere. In general, I don't think the endpoint really "returns" anything, so a custom datatype might let other combinators work better with this library by making it easier to handle edge cases like this without clobbering another use case.

@dnikolovv
Copy link

Any solution to this?

I tried @SamProtas's suggestion, but I get • Overlapping instances for Servant.Auth.Server.Internal.AddSetCookie.AddSetCookies.

@Gab0
Copy link

Gab0 commented Dec 17, 2022

Hello, I can use Servant.Auth with Raw. But when I have a server with Servant.Auth and a Servant.WebSockets endpoint I get the same error as @dnikolovv. Does anyone manage to solve this or have an idea on how to start?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants