-
Notifications
You must be signed in to change notification settings - Fork 7
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
Question: please advise on how to combine RawM with servant-auth's Auth combinator #7
Comments
You can simplify the error message to something like the following:
If you look at
I think this error is occurring because there is no instance for I think there are a couple ways to fix this. The "best" way to fix it would be create a package called Another solution would be to just add this instance to The hackiest (but easiest) solution would just be to create the type instance in your own code. I think it should look like this: type instance AddSetCookieApi (RawM' a) = RawM' a |
Thank you for the quick response! I have just tried this out, and I get a different error, which I think may also be related to type family instances. • Couldn't match type ‘Network.Wai.Internal.Request
-> (Network.Wai.Internal.Response
-> IO Network.Wai.Internal.ResponseReceived)
-> IO Network.Wai.Internal.ResponseReceived’
with ‘Headers '[Header "Set-Cookie" SetCookie] cookied1’
arising from a use of ‘hoistServerWithContext’
• In the expression:
hoistServerWithContext
@ProtectedRaw
Proxy
(Proxy :: Proxy '[CookieSettings, JWTSettings])
(appToHandler env)
In the expression:
hoistServerWithContext
@ProtectedRaw
Proxy
(Proxy :: Proxy '[CookieSettings, JWTSettings])
(appToHandler env)
$ protectedRawR cs jwts
In an equation for ‘server'’:
server'
= hoistServerWithContext
@ProtectedRaw
Proxy
(Proxy :: Proxy '[CookieSettings, JWTSettings])
(appToHandler env)
$ protectedRawR cs jwts This looks like it's just a type mismatch; it seems that the type computed for Thanks for the pointer about the type families, there are additional ones used in the constraint pf the |
Yeah, I'm not sure what this error is caused by! If you have any trouble figuring it out, you can post a link to a repo and I'll dig in a little and try to figure it out. (If the code is private, then a minimal repro would work too.) If you can figure out what the problem is, then packaging the fix up in a new repo or PR, or even just posting it here would probably be helpful for other people! |
Thanks! I also had to an -- Type instance for RawM for SetCookie API
type instance AddSetCookieApi (RawM' a) = RawM' a
-- Provide an @AddSetCookies@ instance for functors of Application.
instance (Functor m)
=> AddSetCookies ('S n) (m Application) (m Application) where
addSetCookies cookies = (fmap $ addSetCookies cookies) I don't mind putting this into a package called servant-auth-rawm if you are happy to accept a PR. |
@adetokunbo Yeah, that works for me! |
Hi, and thank you for producing a really useful extension to servant
I'm trying to use it with servant-auth. I declare a route that uses both
RawM
andAuth
in a custom Monad e.g.this fails to compile with the following message:
Is that expected ?
Is there something wrong with how
hoistServerWithContext
is used here?Will it be necessary to write a distinct
HasServer
instance that combines the two combinators ?The text was updated successfully, but these errors were encountered: