是否可以使用 ghc 7.8 OverlappingInstances 指定哪个实例重叠以及哪个实例可重叠?
我正在尝试在servant/servant-server 包中进行一些更新/更改。一切都编译得很好,所有测试都通过了,除了一个 doctest 在我为 Raw 添加这个更改之前通过了 Enter 实例。doctest 仅在 ghc 7.8 上失败,并在 ghc 7.10 上通过。我相信这与 ghc 7.10 我可以指定哪个实例是重叠的以及哪个实例是可重叠的这一事实有关。ghc 7.8 我怎样才能做到这一点?任何想法/指针将不胜感激。这是我在 ghc 7.8 上遇到的 doctest 和失败错误:
-- >>> 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