Is it possible to specify which instance is overlapping and which instance is overlappable with ghc 7.8 OverlappingInstances?
I am trying to make some updates/changes in the servant/servant-server packages. Everything compiles fine and all test pass except one doctest which was passing before I added this change Enter instance for Raw. The doctest only fails on ghc 7.8, and passes on ghc 7.10. I believe this is related to the fact that ghc 7.10 I can specify which instance is overlapping and which instance is overlappable. How can I accomplish this is ghc 7.8? Any ideas/pointers would be greatly appreciated. Here is the doctest and failing error I am getting on ghc 7.8:
-- >>> import Control.Monad.Reader
-- >>> import qualified Control.Category as C
-- >>> type ReaderAPI = "ep1" :> Get '[JSON] Int :<|> "ep2" :> Get '[JSON] String
-- >>> let readerServer = return 1797 :<|> ask :: ServerT ReaderAPI (Reader String)
-- >>> let mainServer = enter (generalizeNat C.. (runReaderTNat "hi")) readerServer :: Server ReaderAPI
--
-- $setup
-- >>> import Servant.API
-- >>> import Servant.Server
-- Error
### Failure in src/Servant/Server.hs:129: expression `let mainServer = enter (generalizeNat C.. (runReaderTNat "hi")) readerServer :: Server ReaderAPI'
expected:
but got:
<interactive>:44:18:
Couldn't match type ‘Control.Monad.Trans.Either.EitherT
ServantErr IO [Char]’
with ‘ReaderT String Data.Functor.Identity.Identity [Char]’
In the expression:
enter (generalizeNat C.. (runReaderTNat "hi")) readerServer ::
Server ReaderAPI
In an equation for ‘mainServer’:
mainServer
= enter (generalizeNat C.. (runReaderTNat "hi")) readerServer ::
Server ReaderAPI
This is not possible with OverlappingInstances in 7.8. Need to rewrite instances so there is no need for the OverlappingInstances pragma.