Migration in Haskell from stack lts-8.6 to lts-9.3

73 views Asked by At

I used the stack lts-8.6 in my Haskell project. Below is my code that is compiled correctly with lts-8.6:

type AppM = ReaderT App (ExceptT ServantErr IO) 

type ServletAPI = ResourcesAPI
             :<|> MapTitleAPI

server :: ServerT ServletAPI AppM
server = serverResourcesAPI
    :<|> serverMapTitleAPI

type API = ServletAPI 
      :<|> Raw

runWebServerNibes :: App 
                  -> IO ()
runWebServerNibes app = do 
    run (app_portServer . app_serverHTTP . appSettings $ app) $ appNubes app

appNubes :: App -> Application
appNubes app = serve api (readerServer app)

readerServer :: App -> Server API
readerServer app = enter (readerToExcept app) server
                    :<|> serveDirectory (app_pathFolderStatic . app_serverHTTP . appSettings $ app)

readerToExcept :: App -> AppM :~> ExceptT ServantErr IO
readerToExcept app = Nat $ \x -> runReaderT x app

api :: Proxy API
api = Proxy

For lts-9.3, I replaced Nat by NT. But when I use lts-9.3, I get an error:

 • Couldn't match type ‘ImportWSN.Handler’
                     with ‘ExceptT ServantErr IO’
        arising from a functional dependency between:
          constraint ‘Servant.Utils.Enter.Enter
                        (ReaderT App IO Data.Text.Internal.Text)
                        (ReaderT App IO)
                        (ExceptT ServantErr IO)
                        (ImportWSN.Handler Data.Text.Internal.Text)’
            arising from a use of ‘enter’
          instance ‘Servant.Utils.Enter.Enter (m a) m n (n a)’
            at <no location info>
    • In the first argument of ‘(:<|>)’, namely
        ‘enter (readerToExcept app) server’
      In the expression:
        enter (readerToExcept app) server
        :<|>
          serveDirectory
            (app_pathFolderStatic . app_serverHTTP . appSettings $ app)
      In an equation for ‘readerServer’:
          readerServer app
            = enter (readerToExcept app) server
              :<|>
                serveDirectory
                  (app_pathFolderStatic . app_serverHTTP . appSettings $ app)

and

 • Couldn't match type ‘IO’ with ‘ExceptT ServantErr IO’
      Expected type: ReaderT App (ExceptT ServantErr IO) x
        Actual type: AppM x
    • In the first argument of ‘runReaderT’, namely ‘x’
      In the expression: runReaderT x app
      In the second argument of ‘($)’, namely ‘\ x -> runReaderT x app’

I can not understand what changes to make to my code, so that it becomes a worker!

0

There are 0 answers