{-# LANGUAGE RankNTypes #-}
module Control.Monad.Trans.Fail.Text (
Fail,
runFail,
runFailLast,
runFailAgg,
errorFail,
errorFailWithoutStackTrace,
FailT,
F.FailException (..),
failT,
runFailT,
runFailLastT,
runFailAggT,
hoistFailT,
mapFailT,
mapErrorFailT,
mapErrorsFailT,
exceptFailT,
throwFailT,
) where
import Control.Monad.Catch (MonadThrow)
import Control.Monad.Except
import qualified Control.Monad.Trans.Fail as F
import Data.Text (Text)
import GHC.Stack
type Fail = F.Fail Text
runFail :: Fail a -> Either Text a
runFail :: forall a. Fail a -> Either Text a
runFail = forall e a. (IsString e, Semigroup e) => Fail e a -> Either e a
F.runFail
{-# INLINE runFail #-}
runFailLast :: Fail a -> Either Text a
runFailLast :: forall a. Fail a -> Either Text a
runFailLast = forall e a. IsString e => Fail e a -> Either e a
F.runFailLast
{-# INLINE runFailLast #-}
runFailAgg :: Fail a -> Either [Text] a
runFailAgg :: forall a. Fail a -> Either [Text] a
runFailAgg = forall e a. Fail e a -> Either [e] a
F.runFailAgg
{-# INLINE runFailAgg #-}
errorFail :: HasCallStack => Fail a -> a
errorFail :: forall a. HasCallStack => Fail a -> a
errorFail = forall e a. (Show e, HasCallStack) => Fail e a -> a
F.errorFail
errorFailWithoutStackTrace :: Fail a -> a
errorFailWithoutStackTrace :: forall a. Fail a -> a
errorFailWithoutStackTrace = forall e a. Show e => Fail e a -> a
F.errorFailWithoutStackTrace
type FailT = F.FailT Text
failT :: Applicative m => Text -> FailT m a
failT :: forall (m :: * -> *) a. Applicative m => Text -> FailT m a
failT = forall (m :: * -> *) e a. Applicative m => e -> FailT e m a
F.failT
{-# INLINE failT #-}
runFailT :: Functor m => FailT m a -> m (Either Text a)
runFailT :: forall (m :: * -> *) a. Functor m => FailT m a -> m (Either Text a)
runFailT = forall e (m :: * -> *) a.
(IsString e, Semigroup e, Functor m) =>
FailT e m a -> m (Either e a)
F.runFailT
{-# INLINE runFailT #-}
runFailLastT :: Functor m => FailT m a -> m (Either Text a)
runFailLastT :: forall (m :: * -> *) a. Functor m => FailT m a -> m (Either Text a)
runFailLastT = forall e (m :: * -> *) a.
(IsString e, Functor m) =>
FailT e m a -> m (Either e a)
F.runFailLastT
{-# INLINE runFailLastT #-}
runFailAggT :: FailT m a -> m (Either [Text] a)
runFailAggT :: forall (m :: * -> *) a. FailT m a -> m (Either [Text] a)
runFailAggT = forall e (m :: * -> *) a. FailT e m a -> m (Either [e] a)
F.runFailAggT
{-# INLINE runFailAggT #-}
hoistFailT :: (forall a. m a -> n a) -> FailT m b -> FailT n b
hoistFailT :: forall (m :: * -> *) (n :: * -> *) b.
(forall a. m a -> n a) -> FailT m b -> FailT n b
hoistFailT = forall (m :: * -> *) (n :: * -> *) e b.
(forall a. m a -> n a) -> FailT e m b -> FailT e n b
F.hoistFailT
{-# INLINE hoistFailT #-}
mapFailT :: (m (Either [Text] a) -> n (Either [Text] b)) -> FailT m a -> FailT n b
mapFailT :: forall (m :: * -> *) a (n :: * -> *) b.
(m (Either [Text] a) -> n (Either [Text] b))
-> FailT m a -> FailT n b
mapFailT = forall (m :: * -> *) e a (n :: * -> *) b.
(m (Either [e] a) -> n (Either [e] b))
-> FailT e m a -> FailT e n b
F.mapFailT
{-# INLINE mapFailT #-}
mapErrorFailT :: Functor m => (e -> Text) -> F.FailT e m a -> FailT m a
mapErrorFailT :: forall (m :: * -> *) e a.
Functor m =>
(e -> Text) -> FailT e m a -> FailT m a
mapErrorFailT = forall (m :: * -> *) e e' a.
Functor m =>
(e -> e') -> FailT e m a -> FailT e' m a
F.mapErrorFailT
{-# INLINE mapErrorFailT #-}
mapErrorsFailT :: Functor m => ([e] -> [Text]) -> F.FailT e m a -> FailT m a
mapErrorsFailT :: forall (m :: * -> *) e a.
Functor m =>
([e] -> [Text]) -> FailT e m a -> FailT m a
mapErrorsFailT = forall (m :: * -> *) e e' a.
Functor m =>
([e] -> [e']) -> FailT e m a -> FailT e' m a
F.mapErrorsFailT
{-# INLINE mapErrorsFailT #-}
exceptFailT :: (HasCallStack, Monad m) => FailT m a -> ExceptT F.FailException m a
exceptFailT :: forall (m :: * -> *) a.
(HasCallStack, Monad m) =>
FailT m a -> ExceptT FailException m a
exceptFailT = forall e (m :: * -> *) a.
(HasCallStack, Typeable e, Show e, Monad m) =>
FailT e m a -> ExceptT FailException m a
F.exceptFailT
{-# INLINE exceptFailT #-}
throwFailT :: (HasCallStack, MonadThrow m) => FailT m a -> m a
throwFailT :: forall (m :: * -> *) a.
(HasCallStack, MonadThrow m) =>
FailT m a -> m a
throwFailT = forall e (m :: * -> *) a.
(HasCallStack, Typeable e, Show e, MonadThrow m) =>
FailT e m a -> m a
F.throwFailT
{-# INLINE throwFailT #-}