我可以在 7.8 中指定 overlapping/overlappable,就像在 Haskell 中指定 7.10 一样吗?
Can I specify overlapping/overlappable in 7.8 like 7.10 in Haskell?
是否可以使用 ghc 7.8 OverlappingInstances 指定哪个实例重叠以及哪个实例可重叠?
我正在尝试在 servant/servant-server 包中制作一些 updates/changes。一切都编译得很好,所有测试都通过了,除了一个在我添加此更改之前通过的 doctest Enter instance for Raw。 doctest 仅在 ghc 7.8 上失败,并在 ghc 7.10 上通过。我相信这与 ghc 7.10 我可以指定哪个实例重叠以及哪个实例可重叠这一事实有关。我怎样才能做到这一点是 ghc 7.8?任何 ideas/pointers 将不胜感激。这是我在 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
7.8 中的 OverlappingInstances 无法做到这一点。需要重写实例,因此不需要 OverlappingInstances pragma。
是否可以使用 ghc 7.8 OverlappingInstances 指定哪个实例重叠以及哪个实例可重叠?
我正在尝试在 servant/servant-server 包中制作一些 updates/changes。一切都编译得很好,所有测试都通过了,除了一个在我添加此更改之前通过的 doctest Enter instance for Raw。 doctest 仅在 ghc 7.8 上失败,并在 ghc 7.10 上通过。我相信这与 ghc 7.10 我可以指定哪个实例重叠以及哪个实例可重叠这一事实有关。我怎样才能做到这一点是 ghc 7.8?任何 ideas/pointers 将不胜感激。这是我在 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
7.8 中的 OverlappingInstances 无法做到这一点。需要重写实例,因此不需要 OverlappingInstances pragma。