data MyAppR = MyAppR {
dbPool :: Pool Connection
}
type NewApp = ReaderT (MyAppR) IO
type AppActionNew a = ActionT L.Text NewApp a
type AppServerNew a = ScottyT L.Text NewApp a
type App = IO
type AppServer a = ScottyT L.Text App a
type AppAction a = ActionT L.Text App a
type AppActionT = ActionT L.Text App
How can I define a function such as:
mylift :: AppServer () -> AppServerNew ()
mylift a = undefined
Posting it in case anyone already has a solution, otherwise I'll just be figuring this out. Unfortunately ScottyT
/ ActionT
is not a monad transformer so I can't just do the usual lifting.
The whole reason for this is, I now need a database pool for my application, but I don't wanna bother with changing the AppServer
type everywhere and then lifting in all the places. Probably it's quicker just to combine and mix AppServer
with AppServerNew
.
Initial solution that typechecks - but doesn't seem to work correctly as all 'handlers' respond with 404:
mylift :: AppServer () -> AppServerNew ()
mylift (ScottyT x) = pure $ evalState x def