haskus-utils-variant-3.3: Variant and EADT
Safe HaskellNone
LanguageHaskell2010

Haskus.Utils.Variant.Excepts

Contents

Synopsis

Documentation

newtype Excepts es m a Source #

Constructors

Excepts (m (VEither es a)) 

Instances

Instances details
MonadReader r m => MonadReader r (Excepts e m) Source # 
Instance details

Defined in Haskus.Utils.Variant.Excepts

Methods

ask :: Excepts e m r #

local :: (r -> r) -> Excepts e m a -> Excepts e m a #

reader :: (r -> a) -> Excepts e m a #

MonadTrans (Excepts e) Source # 
Instance details

Defined in Haskus.Utils.Variant.Excepts

Methods

lift :: Monad m => m a -> Excepts e m a #

Monad m => Monad (Excepts es m) Source # 
Instance details

Defined in Haskus.Utils.Variant.Excepts

Methods

(>>=) :: Excepts es m a -> (a -> Excepts es m b) -> Excepts es m b #

(>>) :: Excepts es m a -> Excepts es m b -> Excepts es m b #

return :: a -> Excepts es m a #

Functor m => Functor (Excepts es m) Source # 
Instance details

Defined in Haskus.Utils.Variant.Excepts

Methods

fmap :: (a -> b) -> Excepts es m a -> Excepts es m b #

(<$) :: a -> Excepts es m b -> Excepts es m a #

MonadFail m => MonadFail (Excepts es m) Source # 
Instance details

Defined in Haskus.Utils.Variant.Excepts

Methods

fail :: String -> Excepts es m a #

(Functor m, Monad m) => Applicative (Excepts es m) Source # 
Instance details

Defined in Haskus.Utils.Variant.Excepts

Methods

pure :: a -> Excepts es m a #

(<*>) :: Excepts es m (a -> b) -> Excepts es m a -> Excepts es m b #

liftA2 :: (a -> b -> c) -> Excepts es m a -> Excepts es m b -> Excepts es m c #

(*>) :: Excepts es m a -> Excepts es m b -> Excepts es m b #

(<*) :: Excepts es m a -> Excepts es m b -> Excepts es m a #

Foldable m => Foldable (Excepts es m) Source # 
Instance details

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 #

sum :: Num a => Excepts es m a -> a #

product :: Num a => Excepts es m a -> a #

Traversable m => Traversable (Excepts es m) Source # 
Instance details

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 # 
Instance details

Defined in Haskus.Utils.Variant.Excepts

Methods

liftIO :: IO a -> Excepts es m a #

MonadThrow m => MonadThrow (Excepts e m) Source #

Throws exceptions into the base monad.

Instance details

Defined in Haskus.Utils.Variant.Excepts

Methods

throwM :: Exception e0 => e0 -> Excepts e m a #

MonadCatch m => MonadCatch (Excepts e m) Source #

Catches exceptions from the base monad.

Instance details

Defined in Haskus.Utils.Variant.Excepts

Methods

catch :: Exception e0 => Excepts e m a -> (e0 -> Excepts e m a) -> Excepts e m a #

MonadMask m => MonadMask (Excepts e m) Source # 
Instance details

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 # 
Instance details

Defined in Haskus.Utils.Variant.Excepts

Methods

liftWith :: (forall c. (a -> IO c) -> IO c) -> (a -> Excepts es m b) -> Excepts es m b #

liftWith2 :: (forall c. (a -> b -> IO c) -> IO c) -> (a -> b -> Excepts es m e) -> Excepts es m e #

Show (m (VEither es a)) => Show (Excepts es m a) Source # 
Instance details

Defined in Haskus.Utils.Variant.Excepts

Methods

showsPrec :: Int -> Excepts es m a -> ShowS #

show :: Excepts es m a -> String #

showList :: [Excepts es m a] -> ShowS #

runE :: forall es a m. Excepts es m a -> m (VEither es a) Source #

Run an Excepts

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

failureE :: forall e a m. Monad m => e -> Excepts '[e] m a Source #

Signal an exception value e.

successE :: forall a m. Monad m => a -> Excepts '[] m a Source #

Signal a success

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.

evalE :: Monad m => Excepts '[] m a -> m a Source #

Convert a flow without error into a value

onE_ :: Monad m => m () -> Excepts es m a -> Excepts es m a Source #

Do something in case of error

onE :: Monad m => (V es -> m ()) -> Excepts es m a -> Excepts es m a Source #

Do something in case of error

finallyE :: Monad m => m () -> Excepts es m a -> Excepts es m a Source #

Finally for Excepts

injectExcepts :: forall es a m. Monad m => Excepts es m a -> Excepts es m (VEither es a) Source #

withExcepts :: Monad m => (VEither es a -> m b) -> Excepts es m a -> Excepts es m b Source #

withExcepts_ :: Monad m => (VEither es a -> m ()) -> Excepts es m a -> Excepts es m a Source #

mapExcepts :: (m (VEither es a) -> n (VEither es' b)) -> Excepts es m a -> Excepts es' n b Source #

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