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

Raw can only be the last

Open domenkozar opened this issue 6 years ago • 0 comments

diff --git a/servant-auth-server/test/Servant/Auth/ServerSpec.hs b/servant-auth-server/test/Servant/Auth/ServerSpec.hs
index f5047cd..22a1e60 100644
--- a/servant-auth-server/test/Servant/Auth/ServerSpec.hs
+++ b/servant-auth-server/test/Servant/Auth/ServerSpec.hs
@@ -398,8 +398,8 @@ type API auths
     = Auth auths User :>
         ( Get '[JSON] Int
        :<|> ReqBody '[JSON] Int :> Post '[JSON] Int
-       :<|> "header" :> Get '[JSON] (Headers '[Header "Blah" Int] Int)
        :<|> "raw" :> Raw
+       :<|> "header" :> Get '[JSON] (Headers '[Header "Blah" Int] Int)
         )
       :<|> "login" :> ReqBody '[JSON] User :> Post '[JSON] (Headers '[ Header "Set-Cookie" SetCookie
                                                                      , Header "Set-Cookie" SetCookie ] NoContent)
@@ -466,8 +466,9 @@ server ccfg =
     (\authResult -> case authResult of
         Authenticated usr -> getInt usr
                         :<|> postInt usr
-                        :<|> getHeaderInt
                         :<|> raw
+                        :<|> getHeaderInt
+
         Indefinite -> throwAll err401
         _ -> throwAll err403
     )

results into

    /home/ielectric/dev/servant-auth/servant-auth-server/test/Servant/Auth/ServerSpec.hs:455:26: error:
        * Overlapping instances for Servant.Auth.Server.Internal.AddSetCookie.AddSetCookies
                                      ('Servant.Auth.Server.Internal.AddSetCookie.S
                                         ('Servant.Auth.Server.Internal.AddSetCookie.S
                                            'Servant.Auth.Server.Internal.AddSetCookie.Z))
                                      (Tagged Handler Application
                                       :<|> Handler (Headers '[Header "Blah" Int] Int))
                                      (Tagged Handler Application
                                       :<|> Handler
                                              (Headers
                                                 '[Header "Set-Cookie" SetCookie,
                                                   Header "Set-Cookie" SetCookie, Header "Blah" Int]
                                                 Int))
            arising from a use of `serveWithContext'
          Matching instances:
            two instances involving out-of-scope types
            (use -fprint-potential-instances to see them all)
        * In the expression: serveWithContext api ctx
          In the expression: serveWithContext api ctx $ server ccfg
          In an equation for `appWithCookie':
              appWithCookie api ccfg
                = serveWithContext api ctx $ server ccfg
                where
                    ctx = ccfg :. jwtCfg :. theKey :. EmptyContext
        |
    455 | appWithCookie api ccfg = serveWithContext api ctx $ server ccfg
        |                          ^^^^^^^^^^^^^^^^^^^^^^^^

domenkozar avatar Feb 20 '19 14:02 domenkozar