module Data.Automaton.Trans.Except.Internal where

-- transformers
import Control.Monad.Trans.Except (ExceptT (..), runExceptT)
import Control.Monad.Trans.Reader

commuteReader :: ReaderT r (ExceptT e m) a -> ExceptT e (ReaderT r m) a
commuteReader :: forall r e (m :: Type -> Type) a.
ReaderT r (ExceptT e m) a -> ExceptT e (ReaderT r m) a
commuteReader = 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 (ExceptT e m) a -> ReaderT r m (Either e a))
-> ReaderT r (ExceptT e m) a
-> ExceptT e (ReaderT r m) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (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))
-> (ReaderT r (ExceptT e m) a -> r -> m (Either e a))
-> ReaderT r (ExceptT e m) a
-> ReaderT r m (Either e a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ExceptT e m a -> m (Either e a))
-> (r -> ExceptT e m a) -> r -> m (Either e a)
forall a b. (a -> b) -> (r -> a) -> r -> b
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
fmap ExceptT e m a -> m (Either e a)
forall e (m :: Type -> Type) a. ExceptT e m a -> m (Either e a)
runExceptT ((r -> ExceptT e m a) -> r -> m (Either e a))
-> (ReaderT r (ExceptT e m) a -> r -> ExceptT e m a)
-> ReaderT r (ExceptT e m) a
-> r
-> m (Either e a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. 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

commuteReaderBack :: ExceptT e (ReaderT r m) a -> ReaderT r (ExceptT e m) a
commuteReaderBack :: forall e r (m :: Type -> Type) a.
ExceptT e (ReaderT r m) a -> ReaderT r (ExceptT e m) a
commuteReaderBack = (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)
-> (ExceptT e (ReaderT r m) a -> r -> ExceptT e m a)
-> ExceptT e (ReaderT r m) a
-> ReaderT r (ExceptT e m) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (m (Either e a) -> ExceptT e m a)
-> (r -> m (Either e a)) -> r -> ExceptT e m a
forall a b. (a -> b) -> (r -> a) -> r -> b
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
fmap m (Either e a) -> ExceptT e m a
forall e (m :: Type -> Type) a. m (Either e a) -> ExceptT e m a
ExceptT ((r -> m (Either e a)) -> r -> ExceptT e m a)
-> (ExceptT e (ReaderT r m) a -> r -> m (Either e a))
-> ExceptT e (ReaderT r m) a
-> r
-> ExceptT e m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. 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 (ReaderT r m (Either e a) -> r -> m (Either e a))
-> (ExceptT e (ReaderT r m) a -> ReaderT r m (Either e a))
-> ExceptT e (ReaderT r m) a
-> r
-> m (Either e a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. 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