2016-05-19 3 views
2

J'ai utilisé le servant-0.4.4.7. Ci-dessous mon code modèle:Migration de serviteur-0.4.4.7 à serviteur-0.7.1

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 

Ce code worked.But lorsque j'utilise servant-0.7.1, je reçois l'erreur:

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)’ 

Je comprends qu'il ya une incompatibilité de type, mais comment y remédier, Je ne peux pas comprendre.

Merci!

Répondre

3

Modifier tout EitherT s à ExceptT s (à partir de Control.Monad.Trans.Except dans transformers) devrait faire l'affaire. EitherT provenait du package either, qui a été plié en transformers (sous le nom ExceptT), donc servant, avec de plus en plus de paquets, migré vers ExceptT.

+0

Merci très mach! J'ai essayé d'aimer selon [link] (http://stackoverflow.com/questions/31279943/using-servant-with-readert-io-a), mais j'ai eu des erreurs! – QSpider