cdepillabout / cdepillabout/servant-rawm
Question: please advise on how to combine RawM with servant-auth's Auth combinator
- Dominant language
- Haskell
- Stars
- 16
- Forks
- 7
- PR merge metrics
- No merged PRs in 30d
Description
Hi, and thank you for producing a really useful extension to servant
I'm trying to use it with [servant-auth](https://github.com/haskell-servant/servant-auth#readme). I declare a route that uses both `RawM` and `Auth` in a custom Monad e.g.
```haskell
type ProtectedRaw = (Auth '[Cookie, JWT] Account) :> "protected" :> RawM
protectedRawR
:: CookieSettings
-> JWTSettings -> ServerT ProtectedRaw MainApp
protectedRawR = undefined
-- | The application-level Monad, provides acccess to the configuration
-- information via the Reader Monad.
type MainApp = ReaderT Env (ExceptT ServantErr IO)
-- | Convert a MainApp to a Handler
appToHandler :: Env -> MainApp a -> Handler a
appToHandler env action = do
res <- liftIO $ runExceptT $ runReaderT action env
liftEither res
testServer env = serveWithContext @ProtectedRaw Proxy theContext server'
where
xsrfs = def { xsrfExcludeGet = True }
cs = defaultCookieSettings { cookieXsrfSetting = Just xsrfs }
jwts = defaultJWTSettings $ envSigningKey env
theContext = cs :. jwts :. EmptyContext
server' =
hoistServerWithContext
@ProtectedRaw Proxy
(Proxy :: Proxy '[CookieSettings, JWTSettings])
(appToHandler env) $ protectedRawR cs jwts
```
this fails to compile with the following message:
```haskell
• No instance for (HasServer
(Servant.Auth.Server.Internal.AddSetCookie.AddSetCookieApi
(Servant.Auth.Server.Internal.AddSetCookie.AddSetCookieApi
(Servant.RawM.Internal.API.RawM'
Servant.RawM.Internal.API.FileServer)))
'[CookieSettings, JWTSettings])
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
|
139 | hoistServerWithContext
| ^^^^^^^^^^^^^^^^^^^^^^...
```
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 ?
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the ProtectedRaw example and the hoistServerWithContext call, then inspect the HasServer instances for RawM and servant-auth's Auth combinator. Determine whether their combination is supported and document the required approach or the missing instance; the issue is done when the compile failure has a clear resolution.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell
- Domain
- api
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100