I'd like to stack ResourceT
with the ReaderT
monad. It seems I have two options:
Either place ReaderT
on the bottom or at the top of the stack.
data MyEnv
newtype MyT1 m a = MyT1 { unT1 :: ResourceT (ReaderT MyEnv m) a }
newtype MyT2 m a = MyT2 { unT2 :: ReaderT MyEnv (ResourceT m) a }
What would be better in sence of performance/correctness? What are the general guidelines for stacking ResourceT
with WriterT
or other monads?
ResourceT
is itself just a specializedReaderT
monad—all of the interesting stuff gets executed in lifted IO actions. I haven't benched it, but my guess is that both stacks are equally fast. Furthermore, Readers commute (viaflip
) so the two stacks ought to be semantically identical. – J. Abrahamson