module FRP.Rhine.ClSF.Except.Util where
import Control.Monad.Trans.Except
import Control.Monad.Trans.Reader
commuteExceptReader :: ExceptT e (ReaderT r m) a -> ReaderT r (ExceptT e m) a
commuteExceptReader :: forall e r (m :: Type -> Type) a.
ExceptT e (ReaderT r m) a -> ReaderT r (ExceptT e m) a
commuteExceptReader ExceptT e (ReaderT r m) a
a = (r -> ExceptT e m a) -> ReaderT r (ExceptT e m) a
forall r (m :: Type -> Type) a. (r -> m a) -> ReaderT r m a
ReaderT ((r -> ExceptT e m a) -> ReaderT r (ExceptT e m) a)
-> (r -> ExceptT e m a) -> ReaderT r (ExceptT e m) a
forall a b. (a -> b) -> a -> b
$ \r
r -> m (Either e a) -> ExceptT e m a
forall e (m :: Type -> Type) a. m (Either e a) -> ExceptT e m a
ExceptT (m (Either e a) -> ExceptT e m a)
-> m (Either e a) -> ExceptT e m a
forall a b. (a -> b) -> a -> b
$ ReaderT r m (Either e a) -> r -> m (Either e a)
forall r (m :: Type -> Type) a. ReaderT r m a -> r -> m a
runReaderT (ExceptT e (ReaderT r m) a -> ReaderT r m (Either e a)
forall e (m :: Type -> Type) a. ExceptT e m a -> m (Either e a)
runExceptT ExceptT e (ReaderT r m) a
a) r
r
commuteReaderExcept :: ReaderT r (ExceptT e m) a -> ExceptT e (ReaderT r m) a
commuteReaderExcept :: forall r e (m :: Type -> Type) a.
ReaderT r (ExceptT e m) a -> ExceptT e (ReaderT r m) a
commuteReaderExcept ReaderT r (ExceptT e m) a
a = ReaderT r m (Either e a) -> ExceptT e (ReaderT r m) a
forall e (m :: Type -> Type) a. m (Either e a) -> ExceptT e m a
ExceptT (ReaderT r m (Either e a) -> ExceptT e (ReaderT r m) a)
-> ReaderT r m (Either e a) -> ExceptT e (ReaderT r m) a
forall a b. (a -> b) -> a -> b
$ (r -> m (Either e a)) -> ReaderT r m (Either e a)
forall r (m :: Type -> Type) a. (r -> m a) -> ReaderT r m a
ReaderT ((r -> m (Either e a)) -> ReaderT r m (Either e a))
-> (r -> m (Either e a)) -> ReaderT r m (Either e a)
forall a b. (a -> b) -> a -> b
$ \r
r -> ExceptT e m a -> m (Either e a)
forall e (m :: Type -> Type) a. ExceptT e m a -> m (Either e a)
runExceptT (ExceptT e m a -> m (Either e a))
-> ExceptT e m a -> m (Either e a)
forall a b. (a -> b) -> a -> b
$ ReaderT r (ExceptT e m) a -> r -> ExceptT e m a
forall r (m :: Type -> Type) a. ReaderT r m a -> r -> m a
runReaderT ReaderT r (ExceptT e m) a
a r
r