I use a user monad (with a reader) to easily pass data, such as a database pool, to my handlers (before using the user monad, which I used to pass as an argument to fn).
Here is how I defined my regular monad:
newtype Controller a = Controller
{ runController :: ReaderT ServerEnvironment Handler a
} deriving ( Functor, Applicative, Monad, MonadReader ServerEnvironment,
MonadError ServantErr, MonadIO )
This ServerEnvironmentis the usual data type that I use to transfer my data.
The problem is that for mine AuthHandlerI need to specifically use the function with:
r -> Handler usr
as an authentication handler, I cannot use my custom handler, which will be:
r -> Controller usr
and I also have no way to pass mine ConnectionPool, because the signature cannot be:
ConnPool -> r -> Handler usr
, servant IO?