-
Notifications
You must be signed in to change notification settings - Fork 14
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
additional instances of HasServer
and HasClient
for Throwing in apis that set Headers
#4
Comments
I think this should be mostly fixed with #6. I think the only thing left is to handle apis that set Headers. |
Today I tried to add support for handling APIs that set Headers, but I have run into some difficulty. Here is the existing instance for -- | When @'Throwing' es@ comes before a 'Verb', change it into the same 'Verb'
-- but returning an @'Envelope' es@.
instance
{-# OVERLAPPABLE #-}
(HasServer (Verb method status ctypes (Envelope es a)) context) =>
HasServer (Throwing es :> Verb method status ctypes a) context where
type ServerT (Throwing es :> Verb method status ctypes a) m =
ServerT (Verb method status ctypes (Envelope es a)) m
route
:: Proxy (Throwing es :> Verb method status ctypes a)
-> Context context
-> Delayed env (ServerT (Verb method status ctypes (Envelope es a)) Handler)
-> Router env
route _ = route (Proxy :: Proxy (Verb method status ctypes (Envelope es a))) I tried to add an additional instance for use with instance
{-# OVERLAPPING #-}
(HasServer (Verb method status ctypes (Headers h (Envelope es a))) context) =>
HasServer (Throwing es :> Verb method status ctypes (Headers h a)) context where
type ServerT (Throwing es :> Verb method status ctypes (Headers h a)) m =
ServerT (Verb method status ctypes (Headers h (Envelope es a))) m
route
:: Proxy (Throwing es :> Verb method status ctypes (Headers h a))
-> Context context
-> Delayed
env
( ServerT
(Verb method status ctypes (Headers h (Envelope es a)))
Handler
)
-> Router env
route _ =
route (Proxy :: Proxy (Verb method status ctypes (Headers h (Envelope es a)))) However, this is failing with the following error:
Here are some links related to this error:
It doesn't look like there is an easy way to fix this. |
Right, when type families conflict that much their answers have to "be compatible". I'm thinking it might be worth putting all our brainpower on haskell-servant/servant#841 instead of fighting that kind of problem =) If we re-engineer |
HasServer
and HasClient
HasServer
and HasClient
for Headers
HasServer
and HasClient
for HeadersHasServer
and HasClient
for Throwing in apis that set Headers
It looks like servant-auth defines a single type class and related type family for determining how to modify the response type to add headers: I wonder if something similar to this could be adopted for servant-checked-exceptions. |
Right now there are only a few instances of
HasServer
andHasClient
forThrows
andThrowing
.It would be nice to have more.
These should be relatively easy to write.
The text was updated successfully, but these errors were encountered: