堆叠ResourceT monad变换器

sch*_*kin 11 haskell monad-transformers

我想堆ResourceTReaderT单子.看来我有两个选择:放在ReaderT堆栈的底部或顶部.

data MyEnv

newtype MyT1 m a = MyT1 { unT1 :: ResourceT (ReaderT MyEnv m) a }

newtype MyT2 m a = MyT2 { unT2 :: ReaderT MyEnv (ResourceT m) a }
Run Code Online (Sandbox Code Playgroud)

在性能/正确性方面哪些更好?什么是堆叠的一般准则ResourceTWriterT或其他单子?

Boy*_*Jr. 1

就正确性而言,它们都是同样正确的——请参阅@J.Abrahamson 和@Michael Snoyman 的评论。

Performance probably depends on use, in particular it will change how many calls to lift cross that particular layer, which should be the main performance difference. I'd imagine most fair benchmarks would show little to no difference. For whole program performance, profiling is king.