{"action":"created","issue":{"url":"https://api.github.com/repos/haskell-servant/servant/issues/421","repository_url":"https://api.github.com/repos/haskell-servant/servant","labels_url":"https://api.github.com/repos/haskell-servant/servant/issues/421/labels{/name}","comments_url":"https://api.github.com/repos/haskell-servant/servant/issues/421/comments","events_url":"https://api.github.com/repos/haskell-servant/servant/issues/421/events","html_url":"https://github.com/haskell-servant/servant/issues/421","id":142417333,"number":421,"title":"Upgrading to servant-0.5:   Overlapping instances for Servant.API.ContentTypes.AllCTRender","user":{"login":"ecognium","id":5145424,"avatar_url":"https://avatars.githubusercontent.com/u/5145424?v=3","gravatar_id":"","url":"https://api.github.com/users/ecognium","html_url":"https://github.com/ecognium","followers_url":"https://api.github.com/users/ecognium/followers","following_url":"https://api.github.com/users/ecognium/following{/other_user}","gists_url":"https://api.github.com/users/ecognium/gists{/gist_id}","starred_url":"https://api.github.com/users/ecognium/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ecognium/subscriptions","organizations_url":"https://api.github.com/users/ecognium/orgs","repos_url":"https://api.github.com/users/ecognium/repos","events_url":"https://api.github.com/users/ecognium/events{/privacy}","received_events_url":"https://api.github.com/users/ecognium/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-03-21T17:34:24Z","updated_at":"2016-03-23T04:32:01Z","closed_at":null,"body":"I am trying to port my `servant-0.4.*` project to 0.5 and I am not sure how to handle overlapping instance for Content Types. \r\n\r\nI used to have this for serving a dynamic blob (see https://github.com/haskell-servant/servant/issues/400) \r\n\r\n     instance Accept BLOB where\r\n         contentType _ = \"image\" M.// \"jpeg\"\r\n     \r\n     instance MimeRender BLOB BlobFile where\r\n         mimeRender _ = blobContent  \r\n     \r\n     instance {-# OVERLAPPING #-} (AllMimeRender xs BlobFile) => AllCTRender xs BlobFile where\r\n       handleAcceptH _ _ (BlobFile h c) = Just (h, c)\r\n\r\nI added the `(AllMimeRender xs BlobFile)` part for `servant-0.5`.  When I compile the above with `servant-0.5` I get this error: \r\n\r\n    Overlapping instances for Servant.API.ContentTypes.AllCTRender\r\n                                '[BLOB] BlobFile\r\n      arising from a use of ‘serve’\r\n    Matching instances:\r\n      instance [overlappable] Servant.API.ContentTypes.AllMimeRender\r\n                                (ct : cts) a =>\r\n                              Servant.API.ContentTypes.AllCTRender (ct : cts) a\r\n        -- Defined in ‘Servant.API.ContentTypes’\r\n      instance [overlapping] Servant.API.ContentTypes.AllMimeRender\r\n                               xs BlobFile =>\r\n                             Servant.API.ContentTypes.AllCTRender xs BlobFile\r\n        -- Defined at src/JSON/JModels.hs:120:30\r\n    In the expression: serve userAPI (readerServer cfg)\r\n    In an equation for ‘app’:\r\n        app cfg = serve userAPI (readerServer cfg)\r\n\r\nThis is how I am constructing the `Application`\r\n\r\n     type AppM = ReaderT Config (ExceptT ServantErr IO)\r\n\r\n     app :: Config -> Application\r\n     app cfg = serve userAPI (readerServer cfg)\r\n     \r\n     readerServer :: Config -> Server API\r\n     readerServer cfg = enter (readerToExcept cfg) server\r\n     \r\n     readerToExcept :: Config -> AppM :~> ExceptT ServantErr IO\r\n     readerToExcept cfg = Nat $ \\x -> runReaderT x cfg\r\n\r\n\r\n**Note**:  If I remove the entire overlapping instance declaration for `AllCTRender`, my project compiles fine in `servant-0.5`.  Unfortunately, I need that declaration to serve dynamic blob files. \r\n"},"comment":{"url":"https://api.github.com/repos/haskell-servant/servant/issues/comments/200169414","html_url":"https://github.com/haskell-servant/servant/issues/421#issuecomment-200169414","issue_url":"https://api.github.com/repos/haskell-servant/servant/issues/421","id":200169414,"user":{"login":"soenkehahn","id":402539,"avatar_url":"https://avatars.githubusercontent.com/u/402539?v=3","gravatar_id":"","url":"https://api.github.com/users/soenkehahn","html_url":"https://github.com/soenkehahn","followers_url":"https://api.github.com/users/soenkehahn/followers","following_url":"https://api.github.com/users/soenkehahn/following{/other_user}","gists_url":"https://api.github.com/users/soenkehahn/gists{/gist_id}","starred_url":"https://api.github.com/users/soenkehahn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/soenkehahn/subscriptions","organizations_url":"https://api.github.com/users/soenkehahn/orgs","repos_url":"https://api.github.com/users/soenkehahn/repos","events_url":"https://api.github.com/users/soenkehahn/events{/privacy}","received_events_url":"https://api.github.com/users/soenkehahn/received_events","type":"User","site_admin":false},"created_at":"2016-03-23T04:32:01Z","updated_at":"2016-03-23T04:32:01Z","body":"Ah, I think now I understand the issue better. You want to be able to dynamically set the `Content-Type` of the response depending on the value of the data (e.g. `ByteString`) you're sending. Is that correct?\r\n\r\nIf so, this is a use-case that isn't directly supported by `servant`. So I guess it was a bit coincidental that you managed to make that work in `servant-0.4` (kudos for that).\r\n\r\nHope you make it work with the new version too. I'd be interested to see the code, if you do."}}