servant-websockets icon indicating copy to clipboard operation
servant-websockets copied to clipboard

WebSocket has fewer instances than Raw

Open 3noch opened this issue 7 years ago • 5 comments

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 avatar Oct 03 '17 20:10 3noch

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.

moesenle avatar Oct 07 '17 08:10 moesenle

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!

3noch avatar Oct 10 '17 21:10 3noch

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.

SamProtas avatar Jun 29 '18 21:06 SamProtas

Any solution to this?

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

dnikolovv avatar Sep 26 '19 11:09 dnikolovv

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?

Gab0 avatar Dec 17 '22 16:12 Gab0