4 ms·
I think (I am not sure) that you cannot define monad composition (transformer) with IO because IO is purposely open-world (so that Haskell can use C libraries a
by js8 5y ago
I think (I am not sure) that you cannot define monad composition (transformer) with IO because IO is purposely open-world (so that Haskell can use C libraries and OS calls) and as such is not entirely formally defined. If we defined it as a closed-world, i.e. these are the side effects that you can do with IO and nothing else, then it might become possible to compose with other monads.
- hither_shores 5y agoMonad transformers aren't quite the same thing as composed monads. (In fact, they're kind of a kludge to deal with the fact that monad composition isn't very well behaved.) Some monad transformers, like `MaybeT m a`, are just wrappers around a composed `m (Maybe a)`, but others, like the continuation passing transformer `ContT r m a = (a -> m r) -> m r`, are very much not.