'ExceptT ResourceT' vs 'ResourceT ExceptT'

Real World Haskell claims that "the installation order of the transformer is important . " However, I cannot understand if there is a difference between ExceptT (ResourceT m) a and ResourceT (ExceptT m) a . Will they interfere with each other?

+5
source share
1 answer

In this example, there is no real difference between the two orders. The reason is that, unlike many transformers, including ExceptT , the resource transformer does not "enter" its own actions into the base monad to which you apply it, but rather begin the whole action by passing the links to the release.

If you write out types (I will refer to MaybeT instead of ExceptT for simplicity, they are obviously equivalent for this question), then you have basically

 type MaybeResourceT ma = MaybeT (IORef RelMap -> ma) = IORef RelMap -> m (Maybe a) type ResourceMaybeT ma = ResourceT (m (Maybe a)) = IORef RelMap -> m (Maybe a) 

i.e. actually equivalent types. I suppose you could also show this for operations.

+4
source

Source: https://habr.com/ru/post/1238878/


All Articles