我可以在6.8中指定重叠/可重叠,如Haskell中的7.10吗?

时间:2015-08-18 20:47:07

标签: haskell ghc overlapping-instances

是否可以指定哪个实例重叠以及哪个实例可与ghc重叠7.8重叠实例?

我正在尝试在servant / servant-server软件包中进行一些更新/更改。除了在我添加此更改Enter instance for Raw之前通过的一个doctest之外,所有内容都编译良好且所有测试通过。 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

1 个答案:

答案 0 :(得分:0)

7.8中的OverlappingInstances无法做到这一点。需要重写实例,因此不需要OverlappingInstances pragma。