The instance would be
instance (ScottyError e, Monad m, MonadReader r m) => MonadReader r (ActionT e (ReaderT r m)) where
However Scotty does not expose the required functions to implement local.
I am attempting to write a mapActionT
to make it possible to implement local
and I will update this answer if I ever figure out the types to do that :)
Edit:
I think I have mapActionT, but I'm not sure.
mapActionT :: (Monad m, Functor n, ScottyError e) => (forall a . m a -> n a) -> ActionT e m b -> ActionT e n b
mapActionT nat m = ActionT $ flip mapErrorT (runAM m) $ \rt ->
flip mapReaderT rt $ \st ->
StateT $ \s -> fmap (\a -> (a,s)) (nat (evalStateT st s))
I ended up copying the type signature from hoist so that I could bring in Functor n for my fmap.
Any comments on the implementation are welcome.