Safe Haskell | None |
---|---|
Language | Haskell2010 |
Haskus.Utils.Variant.Excepts
Contents
Synopsis
- newtype Excepts es m a = Excepts (m (VEither es a))
- runE :: forall es a m. Excepts es m a -> m (VEither es a)
- runE_ :: forall es a m. Functor m => Excepts es m a -> m ()
- liftE :: forall es' es a m. (Monad m, VEitherLift es es') => Excepts es m a -> Excepts es' m a
- appendE :: forall ns es a m. Monad m => Excepts es m a -> Excepts (Concat es ns) m a
- prependE :: forall ns es a m. (Monad m, KnownNat (Length ns)) => Excepts es m a -> Excepts (Concat ns es) m a
- failureE :: forall e a m. Monad m => e -> Excepts '[e] m a
- successE :: forall a m. Monad m => a -> Excepts '[] m a
- throwE :: forall e es a m. (Monad m, e :< es) => e -> Excepts es m a
- throwSomeE :: forall es' es a m. (Monad m, LiftVariant es' es) => V es' -> Excepts es m a
- catchE :: forall e es' es'' es a m. (Monad m, e :< es, LiftVariant (Remove e es) es', LiftVariant es'' es') => (e -> Excepts es'' m a) -> Excepts es m a -> Excepts es' m a
- catchEvalE :: Monad m => (V es -> m a) -> Excepts es m a -> m a
- evalE :: Monad m => Excepts '[] m a -> m a
- onE_ :: Monad m => m () -> Excepts es m a -> Excepts es m a
- onE :: Monad m => (V es -> m ()) -> Excepts es m a -> Excepts es m a
- finallyE :: Monad m => m () -> Excepts es m a -> Excepts es m a
- injectExcepts :: forall es a m. Monad m => Excepts es m a -> Excepts es m (VEither es a)
- withExcepts :: Monad m => (VEither es a -> m b) -> Excepts es m a -> Excepts es m b
- withExcepts_ :: Monad m => (VEither es a -> m ()) -> Excepts es m a -> Excepts es m a
- mapExcepts :: (m (VEither es a) -> n (VEither es' b)) -> Excepts es m a -> Excepts es' n b
- variantToExcepts :: Monad m => V (a ': es) -> Excepts es m a
- veitherToExcepts :: Monad m => VEither es a -> Excepts es m a
- catchLiftBoth :: forall e es' es'' es a m. (Monad m, e :< es, LiftVariant (Remove e es) es', LiftVariant es'' es') => (e -> Excepts es'' m a) -> Excepts es m a -> Excepts es' m a
- catchLiftLeft :: forall e es es' a m. (Monad m, e :< es, LiftVariant (Remove e es) es') => (e -> Excepts es' m a) -> Excepts es m a -> Excepts es' m a
- catchLiftRight :: forall e es es' a m. (Monad m, e :< es, LiftVariant es' (Remove e es)) => (e -> Excepts es' m a) -> Excepts es m a -> Excepts (Remove e es) m a
- catchAllE :: Monad m => (V es -> Excepts es' m a) -> Excepts es m a -> Excepts es' m a
- catchDieE :: (e :< es, Monad m) => (e -> m ()) -> Excepts es m a -> Excepts (Remove e es) m a
- catchRemove :: forall e es a m. Monad m => (e -> Excepts es m a) -> Excepts (e ': es) m a -> Excepts es m a
- sequenceE :: (KnownNat (Length (b ': e2)), Monad m) => Excepts e1 m a -> Excepts e2 m b -> Excepts (Tail (Product (a ': e1) (b ': e2))) m (a, b)
- runBothE :: (KnownNat (Length (b ': e2)), Monad m) => (forall x y. m x -> m y -> m (x, y)) -> Excepts e1 m a -> Excepts e2 m b -> Excepts (Tail (Product (a ': e1) (b ': e2))) m (a, b)
- module Haskus.Utils.Variant.VEither
Documentation
newtype Excepts es m a Source #
Instances
MonadReader r m => MonadReader r (Excepts e m) Source # | |
MonadTrans (Excepts e) Source # | |
Defined in Haskus.Utils.Variant.Excepts | |
Monad m => Monad (Excepts es m) Source # | |
Functor m => Functor (Excepts es m) Source # | |
MonadFail m => MonadFail (Excepts es m) Source # | |
Defined in Haskus.Utils.Variant.Excepts | |
(Functor m, Monad m) => Applicative (Excepts es m) Source # | |
Defined in Haskus.Utils.Variant.Excepts | |
Foldable m => Foldable (Excepts es m) Source # | |
Defined in Haskus.Utils.Variant.Excepts Methods fold :: Monoid m0 => Excepts es m m0 -> m0 # foldMap :: Monoid m0 => (a -> m0) -> Excepts es m a -> m0 # foldMap' :: Monoid m0 => (a -> m0) -> Excepts es m a -> m0 # foldr :: (a -> b -> b) -> b -> Excepts es m a -> b # foldr' :: (a -> b -> b) -> b -> Excepts es m a -> b # foldl :: (b -> a -> b) -> b -> Excepts es m a -> b # foldl' :: (b -> a -> b) -> b -> Excepts es m a -> b # foldr1 :: (a -> a -> a) -> Excepts es m a -> a # foldl1 :: (a -> a -> a) -> Excepts es m a -> a # toList :: Excepts es m a -> [a] # null :: Excepts es m a -> Bool # length :: Excepts es m a -> Int # elem :: Eq a => a -> Excepts es m a -> Bool # maximum :: Ord a => Excepts es m a -> a # minimum :: Ord a => Excepts es m a -> a # | |
Traversable m => Traversable (Excepts es m) Source # | |
Defined in Haskus.Utils.Variant.Excepts Methods traverse :: Applicative f => (a -> f b) -> Excepts es m a -> f (Excepts es m b) # sequenceA :: Applicative f => Excepts es m (f a) -> f (Excepts es m a) # mapM :: Monad m0 => (a -> m0 b) -> Excepts es m a -> m0 (Excepts es m b) # sequence :: Monad m0 => Excepts es m (m0 a) -> m0 (Excepts es m a) # | |
MonadIO m => MonadIO (Excepts es m) Source # | |
Defined in Haskus.Utils.Variant.Excepts | |
MonadThrow m => MonadThrow (Excepts e m) Source # | Throws exceptions into the base monad. |
Defined in Haskus.Utils.Variant.Excepts | |
MonadCatch m => MonadCatch (Excepts e m) Source # | Catches exceptions from the base monad. |
MonadMask m => MonadMask (Excepts e m) Source # | |
Defined in Haskus.Utils.Variant.Excepts Methods mask :: ((forall a. Excepts e m a -> Excepts e m a) -> Excepts e m b) -> Excepts e m b # uninterruptibleMask :: ((forall a. Excepts e m a -> Excepts e m a) -> Excepts e m b) -> Excepts e m b # generalBracket :: Excepts e m a -> (a -> ExitCase b -> Excepts e m c) -> (a -> Excepts e m b) -> Excepts e m (b, c) # | |
MonadInIO m => MonadInIO (Excepts es m) Source # | |
Show (m (VEither es a)) => Show (Excepts es m a) Source # | |
runE_ :: forall es a m. Functor m => Excepts es m a -> m () Source #
Run an Excepts, discard the result value
liftE :: forall es' es a m. (Monad m, VEitherLift es es') => Excepts es m a -> Excepts es' m a Source #
Lift a Excepts into another
appendE :: forall ns es a m. Monad m => Excepts es m a -> Excepts (Concat es ns) m a Source #
Append errors to an Excepts
prependE :: forall ns es a m. (Monad m, KnownNat (Length ns)) => Excepts es m a -> Excepts (Concat ns es) m a Source #
Prepend errors to an Excepts
throwE :: forall e es a m. (Monad m, e :< es) => e -> Excepts es m a Source #
Signal an exception value e
.
throwSomeE :: forall es' es a m. (Monad m, LiftVariant es' es) => V es' -> Excepts es m a Source #
Throw some exception
catchE :: forall e es' es'' es a m. (Monad m, e :< es, LiftVariant (Remove e es) es', LiftVariant es'' es') => (e -> Excepts es'' m a) -> Excepts es m a -> Excepts es' m a Source #
Handle an exception. Lift both normal and exceptional flows into the result flow
catchEvalE :: Monad m => (V es -> m a) -> Excepts es m a -> m a Source #
Evaluate a Excepts. Use the provided function to handle error cases.
onE :: Monad m => (V es -> m ()) -> Excepts es m a -> Excepts es m a Source #
Do something in case of error
variantToExcepts :: Monad m => V (a ': es) -> Excepts es m a Source #
Convert a Variant into a Excepts
veitherToExcepts :: Monad m => VEither es a -> Excepts es m a Source #
Convert a VEither into a Excepts
catchLiftBoth :: forall e es' es'' es a m. (Monad m, e :< es, LiftVariant (Remove e es) es', LiftVariant es'' es') => (e -> Excepts es'' m a) -> Excepts es m a -> Excepts es' m a Source #
Handle an exception. Lift both normal and exceptional flows into the result flow
catchLiftLeft :: forall e es es' a m. (Monad m, e :< es, LiftVariant (Remove e es) es') => (e -> Excepts es' m a) -> Excepts es m a -> Excepts es' m a Source #
Handle an exception. Lift the remaining errors into the resulting flow
catchLiftRight :: forall e es es' a m. (Monad m, e :< es, LiftVariant es' (Remove e es)) => (e -> Excepts es' m a) -> Excepts es m a -> Excepts (Remove e es) m a Source #
Handle an exception. Lift the handler into the resulting flow
catchAllE :: Monad m => (V es -> Excepts es' m a) -> Excepts es m a -> Excepts es' m a Source #
Do something in case of error
catchDieE :: (e :< es, Monad m) => (e -> m ()) -> Excepts es m a -> Excepts (Remove e es) m a Source #
Catch and die in case of error
catchRemove :: forall e es a m. Monad m => (e -> Excepts es m a) -> Excepts (e ': es) m a -> Excepts es m a Source #
Handle an exception. Assume it is in the first position
sequenceE :: (KnownNat (Length (b ': e2)), Monad m) => Excepts e1 m a -> Excepts e2 m b -> Excepts (Tail (Product (a ': e1) (b ': e2))) m (a, b) Source #
Product of the sequential execution of two Excepts
The second one is run even if the first one failed!
runBothE :: (KnownNat (Length (b ': e2)), Monad m) => (forall x y. m x -> m y -> m (x, y)) -> Excepts e1 m a -> Excepts e2 m b -> Excepts (Tail (Product (a ': e1) (b ': e2))) m (a, b) Source #
Product of the execution of two Excepts
You can use a generic monad combinator such as
concurrently
(in "async" package) to get
concurrent execution.
> concurrentE = runBothE concurrently
Reexport
module Haskus.Utils.Variant.VEither