plow-technologies / servant-streaming

Support for servant requests and responses via the 'streaming' library
13 stars 3 forks source link

Add Header instances for StreamResponse #14

Closed domenkozar closed 5 years ago

domenkozar commented 6 years ago

Hey @jkarni - thanks so much for the help on IRC. I think this is the last bit missing:

Servant/Streaming/Server/Internal.hs:86:10: error:
        * Overlapping instances for GetHeaders (Headers hs a0)
          Matching givens (or their superclasses):
            GetHeaders (Headers hs a)
              bound by an instance declaration:
                         forall (status :: ghc-prim-0.5.2.0:GHC.Types.Nat) (contentTypes :: [*]) (method :: StdMethod) (hs :: [*]) a (ctx :: [*]).
                         (KnownNat status, AllMime contentTypes, ReflectMethod method,
                          GetHeaders (Headers hs a)) =>
                         HasServer
                           (Headers hs (StreamResponse method status contentTypes)) ctx
              at src/Servant/Streaming/Server/Internal.hs:(86,10)-(87,84)
          Matching instances:
            instance Servant.API.ResponseHeaders.GetHeaders' hs =>
                     GetHeaders (Headers hs a)
              -- Defined in `Servant.API.ResponseHeaders'
          (The choice depends on the instantiation of `hs, a0')
        * In the ambiguity check for an instance declaration
          To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
          In the instance declaration for
            `HasServer (Headers hs (StreamResponse method status contentTypes)) ctx'
       |
    86 | instance ( KnownNat status, AllMime contentTypes, ReflectMethod method, GetHeaders (Headers hs a)
       |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...
domenkozar commented 6 years ago

@phadej shouldn't GetHeaders' be exported?

domenkozar commented 6 years ago

Ok, this compiles but needs a slight change to servant:

diff --git a/servant/src/Servant/API/ResponseHeaders.hs b/servant/src/Servant/API/ResponseHeaders.hs
index a0036c93..97700d7d 100644
--- a/servant/src/Servant/API/ResponseHeaders.hs
+++ b/servant/src/Servant/API/ResponseHeaders.hs
@@ -30,6 +30,7 @@ module Servant.API.ResponseHeaders
     , noHeader
     , BuildHeadersTo(buildHeadersTo)
     , GetHeaders(getHeaders)
+    , GetHeaders'
     , HeaderValMap
     , HList(..)
     ) where