2

を使用しましたservant-0.4.4.7。以下は私のモデルコードです:

type API = ServletAPI :<|> Raw

type AppM = ReaderT Config (EitherT ServantErr IO)

runApplication :: IO ()
runApplication = do 
    configApp <- initializationConfig
    case configApp of
        ConfigNull  -> return ()
        otherwise   -> run (opt_portServer . cfg_optionsArg $ configApp) $ app configApp

app :: Config -> Application
app configApp = serve api (readerServer configApp)

readerServer :: Config -> Server API
readerServer configApp = enter (readerToEither configApp) server
                    :<|> serveDirectory (opt_pathFolderStatic . cfg_optionsArg $ configApp)

readerToEither :: Config -> AppM :~> EitherT ServantErr IO
readerToEither configApp = Nat $ \x -> runReaderT x configApp

api :: Proxy API
api = Proxy

このコードは機能しましたが、 を使用するservant-0.7.1とエラーが発生します。

Couldn't match type ‘Control.Monad.Trans.Except.ExceptT
                           ServantErr IO’
                   with ‘EitherT ServantErr IO’
    arising from a functional dependency between:
      constraint ‘Servant.Utils.Enter.Enter
                    (ReaderT Config (EitherT ServantErr IO) Data.Text.Internal.Text)
                    (AppM :~> EitherT ServantErr IO)
                    (Control.Monad.Trans.Except.ExceptT
                       ServantErr IO Data.Text.Internal.Text)’

型の不一致があることは理解していますが、それを修正する方法がわかりません。

ありがとう!

4

1 に答える 1

3

すべてEitherTの s をExceptT( から)Control.Monad.Trans.Exceptに変更するtransformersと、うまくいくはずです。に(名前で)折りたたまれEitherTたパッケージから来たので、ますます多くのパッケージと共に、 に移行しました。eithertransformersExceptTservantExceptT

于 2016-05-19T11:45:07.157 に答える