| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Control.Monad.CheckedExcept
Description
Basic API of CheckedExceptT
Synopsis
- newtype CheckedExceptT (exceptions :: [Type]) (m :: Type -> Type) a = CheckedExceptT {
- runCheckedExceptT :: m (Either (OneOf exceptions) a)
- type CheckedExcept (es :: [Type]) a = CheckedExceptT es Identity a
- data OneOf (es :: [Type])
- oneOf :: forall e (es :: [Type]). (Elem e es, CheckedException e) => e -> OneOf es
- data ElemIx e (es :: [Type]) where
- data Subset (es1 :: [Type]) (es2 :: [Type]) where
- data CaseException x (es :: [Type]) where
- CaseEndWith :: forall x. x -> CaseException x ('[] :: [Type])
- CaseCons :: forall e x (es1 :: [Type]). Typeable e => (e -> x) -> CaseException x es1 -> CaseException x (e ': es1)
- CaseAny :: forall x (es :: [Type]). (forall e. CheckedException e => e -> x) -> CaseException x es
- pattern CaseEnd :: CaseException x ('[] :: [Type])
- newtype ShowException a = ShowException a
- newtype ExceptionException a = ExceptionException a
- class Typeable e => CheckedException e where
- runCheckedExcept :: forall (es :: [Type]) a. CheckedExcept es a -> Either (OneOf es) a
- throwCheckedException :: forall e (es :: [Type]) (m :: Type -> Type) a. (Elem e es, CheckedException e, Applicative m) => e -> CheckedExceptT es m a
- applyAll :: forall b (es :: [Type]). (forall e. CheckedException e => e -> b) -> OneOf es -> b
- weakenExceptions :: forall (exceptions1 :: [Type]) (exceptions2 :: [Type]) (m :: Type -> Type) a. (Functor m, Contains exceptions1 exceptions2) => CheckedExceptT exceptions1 m a -> CheckedExceptT exceptions2 m a
- weakenExceptionsWith :: forall (m :: Type -> Type) (exceptions1 :: [Type]) (exceptions2 :: [Type]) a. Functor m => Subset exceptions1 exceptions2 -> CheckedExceptT exceptions1 m a -> CheckedExceptT exceptions2 m a
- weakenOneOf :: forall (exceptions1 :: [Type]) (exceptions2 :: [Type]). Contains exceptions1 exceptions2 => OneOf exceptions1 -> OneOf exceptions2
- weakenOneOfWith :: forall (exceptions1 :: [Type]) (exceptions2 :: [Type]). Subset exceptions1 exceptions2 -> OneOf exceptions1 -> OneOf exceptions2
- withOneOf :: forall e (es :: [Type]) a. (Monoid a, CheckedException e) => OneOf es -> (e -> a) -> a
- withOneOf' :: forall (es :: [Type]) a. OneOf es -> (forall e. (Elem e es, CheckedException e, Typeable e) => e -> a) -> a
- caseException :: forall (es :: [Type]) x. OneOf es -> CaseException x (Nub es) -> x
- (<:) :: forall e x (es :: [Type]). Typeable e => (e -> x) -> CaseException x es -> CaseException x (e ': es)
- catchSomeException :: forall (m :: Type -> Type) (es :: [Type]) a. (Monad m, MonadCatch m, Elem SomeException es) => CheckedExceptT es m a -> CheckedExceptT es m a
- containsRefl :: forall (es :: [Type]). Subset es es
- lookupSubset :: forall (es1 :: [Type]) (es2 :: [Type]) e. Subset es1 es2 -> ElemIx e es1 -> ElemIx e es2
- class Contains (es1 :: [Type]) (es2 :: [Type])
- class Elem e (es :: [Type])
- type family Elem' (x :: a) (xs :: [a]) :: Bool where ...
- type family NonEmpty (xs :: [a]) where ...
- type NotElemTypeError (x :: t) (xs :: t1) = TypeError (('ShowType x ':<>: 'Text " is not a member of ") ':<>: 'ShowType xs) :: k
- type family Nub (xs :: [a]) :: [a] where ...
- type family Remove (x :: a) (xs :: [a]) :: [a] where ...
- type family (xs :: [k]) ++ (ys :: [k]) :: [k] where ...
Types
newtype CheckedExceptT (exceptions :: [Type]) (m :: Type -> Type) a Source #
Constructors
| CheckedExceptT | |
Fields
| |
Instances
| MonadTrans (CheckedExceptT exceptions) Source # | |
Defined in Control.Monad.CheckedExcept Methods lift :: Monad m => m a -> CheckedExceptT exceptions m a # | |
| Monad m => MonadError (OneOf exceptions) (CheckedExceptT exceptions m) Source # | |
Defined in Control.Monad.CheckedExcept Methods throwError :: OneOf exceptions -> CheckedExceptT exceptions m a # catchError :: CheckedExceptT exceptions m a -> (OneOf exceptions -> CheckedExceptT exceptions m a) -> CheckedExceptT exceptions m a # | |
| Monad m => Applicative (CheckedExceptT exceptions m) Source # | |
Defined in Control.Monad.CheckedExcept Methods pure :: a -> CheckedExceptT exceptions m a # (<*>) :: CheckedExceptT exceptions m (a -> b) -> CheckedExceptT exceptions m a -> CheckedExceptT exceptions m b # liftA2 :: (a -> b -> c) -> CheckedExceptT exceptions m a -> CheckedExceptT exceptions m b -> CheckedExceptT exceptions m c # (*>) :: CheckedExceptT exceptions m a -> CheckedExceptT exceptions m b -> CheckedExceptT exceptions m b # (<*) :: CheckedExceptT exceptions m a -> CheckedExceptT exceptions m b -> CheckedExceptT exceptions m a # | |
| Functor m => Functor (CheckedExceptT exceptions m) Source # | |
Defined in Control.Monad.CheckedExcept Methods fmap :: (a -> b) -> CheckedExceptT exceptions m a -> CheckedExceptT exceptions m b # (<$) :: a -> CheckedExceptT exceptions m b -> CheckedExceptT exceptions m a # | |
| Monad m => Monad (CheckedExceptT exceptions m) Source # | |
Defined in Control.Monad.CheckedExcept Methods (>>=) :: CheckedExceptT exceptions m a -> (a -> CheckedExceptT exceptions m b) -> CheckedExceptT exceptions m b # (>>) :: CheckedExceptT exceptions m a -> CheckedExceptT exceptions m b -> CheckedExceptT exceptions m b # return :: a -> CheckedExceptT exceptions m a # | |
| MonadFail m => MonadFail (CheckedExceptT exceptions m) Source # | |
Defined in Control.Monad.CheckedExcept Methods fail :: HasCallStack => String -> CheckedExceptT exceptions m a # | |
| MonadIO m => MonadIO (CheckedExceptT exceptions m) Source # | |
Defined in Control.Monad.CheckedExcept Methods liftIO :: IO a -> CheckedExceptT exceptions m a # | |
type CheckedExcept (es :: [Type]) a = CheckedExceptT es Identity a Source #
Pure checked exceptions.
data OneOf (es :: [Type]) Source #
A sort of pseudo-open union backed by membership witnesses.
Instances
| Monad m => MonadError (OneOf exceptions) (CheckedExceptT exceptions m) Source # | |
Defined in Control.Monad.CheckedExcept Methods throwError :: OneOf exceptions -> CheckedExceptT exceptions m a # catchError :: CheckedExceptT exceptions m a -> (OneOf exceptions -> CheckedExceptT exceptions m a) -> CheckedExceptT exceptions m a # | |
oneOf :: forall e (es :: [Type]). (Elem e es, CheckedException e) => e -> OneOf es Source #
Construct a checked exception value.
data Subset (es1 :: [Type]) (es2 :: [Type]) where Source #
Witness that every element of es1 is contained in es2.
data CaseException x (es :: [Type]) where Source #
Data type used for constructing a coverage checked case-like catch.
Constructors
| CaseEndWith :: forall x. x -> CaseException x ('[] :: [Type]) | |
| CaseCons :: forall e x (es1 :: [Type]). Typeable e => (e -> x) -> CaseException x es1 -> CaseException x (e ': es1) | |
| CaseAny :: forall x (es :: [Type]). (forall e. CheckedException e => e -> x) -> CaseException x es |
pattern CaseEnd :: CaseException x ('[] :: [Type]) Source #
newtype ShowException a Source #
DerivingVia newtype wrapper to derive CheckedException from a Show instance.
Constructors
| ShowException a |
Instances
| (Show a, Typeable a) => CheckedException (ShowException a) Source # | |
Defined in Control.Monad.CheckedExcept Methods encodeException :: ShowException a -> String Source # fromOneOf :: forall (es :: [Type]). OneOf es -> Maybe (ShowException a) Source # | |
newtype ExceptionException a Source #
DerivingVia newtype wrapper to derive CheckedException from Exception.
Constructors
| ExceptionException a |
Instances
| (Typeable a, Exception a) => CheckedException (ExceptionException a) Source # | |
Defined in Control.Monad.CheckedExcept Methods encodeException :: ExceptionException a -> String Source # fromOneOf :: forall (es :: [Type]). OneOf es -> Maybe (ExceptionException a) Source # | |
Typeclass
class Typeable e => CheckedException e where Source #
The class for checked exceptions.
Minimal complete definition
Nothing
Methods
encodeException :: e -> String Source #
default encodeException :: Exception e => e -> String Source #
fromOneOf :: forall (es :: [Type]). OneOf es -> Maybe e Source #
Instances
| CheckedException SomeException Source # | |
Defined in Control.Monad.CheckedExcept Methods encodeException :: SomeException -> String Source # fromOneOf :: forall (es :: [Type]). OneOf es -> Maybe SomeException Source # | |
| (Typeable a, Exception a) => CheckedException (ExceptionException a) Source # | |
Defined in Control.Monad.CheckedExcept Methods encodeException :: ExceptionException a -> String Source # fromOneOf :: forall (es :: [Type]). OneOf es -> Maybe (ExceptionException a) Source # | |
| (Show a, Typeable a) => CheckedException (ShowException a) Source # | |
Defined in Control.Monad.CheckedExcept Methods encodeException :: ShowException a -> String Source # fromOneOf :: forall (es :: [Type]). OneOf es -> Maybe (ShowException a) Source # | |
Utility functions
runCheckedExcept :: forall (es :: [Type]) a. CheckedExcept es a -> Either (OneOf es) a Source #
Get the error from CheckedExcept.
throwCheckedException :: forall e (es :: [Type]) (m :: Type -> Type) a. (Elem e es, CheckedException e, Applicative m) => e -> CheckedExceptT es m a Source #
applyAll :: forall b (es :: [Type]). (forall e. CheckedException e => e -> b) -> OneOf es -> b Source #
weakenExceptions :: forall (exceptions1 :: [Type]) (exceptions2 :: [Type]) (m :: Type -> Type) a. (Functor m, Contains exceptions1 exceptions2) => CheckedExceptT exceptions1 m a -> CheckedExceptT exceptions2 m a Source #
See weakenOneOfWith.
weakenExceptionsWith :: forall (m :: Type -> Type) (exceptions1 :: [Type]) (exceptions2 :: [Type]) a. Functor m => Subset exceptions1 exceptions2 -> CheckedExceptT exceptions1 m a -> CheckedExceptT exceptions2 m a Source #
Weaken using an explicit subset witness.
weakenOneOf :: forall (exceptions1 :: [Type]) (exceptions2 :: [Type]). Contains exceptions1 exceptions2 => OneOf exceptions1 -> OneOf exceptions2 Source #
See weakenOneOfWith.
weakenOneOfWith :: forall (exceptions1 :: [Type]) (exceptions2 :: [Type]). Subset exceptions1 exceptions2 -> OneOf exceptions1 -> OneOf exceptions2 Source #
withOneOf :: forall e (es :: [Type]) a. (Monoid a, CheckedException e) => OneOf es -> (e -> a) -> a Source #
withOneOf' :: forall (es :: [Type]) a. OneOf es -> (forall e. (Elem e es, CheckedException e, Typeable e) => e -> a) -> a Source #
caseException :: forall (es :: [Type]) x. OneOf es -> CaseException x (Nub es) -> x Source #
(<:) :: forall e x (es :: [Type]). Typeable e => (e -> x) -> CaseException x es -> CaseException x (e ': es) infixr 7 Source #
catchSomeException :: forall (m :: Type -> Type) (es :: [Type]) a. (Monad m, MonadCatch m, Elem SomeException es) => CheckedExceptT es m a -> CheckedExceptT es m a Source #
containsRefl :: forall (es :: [Type]). Subset es es Source #
Reflexive subset witness for abstract exception lists.
lookupSubset :: forall (es1 :: [Type]) (es2 :: [Type]) e. Subset es1 es2 -> ElemIx e es1 -> ElemIx e es2 Source #
Translate a membership index along a subset witness.
Type families / constraints
class Contains (es1 :: [Type]) (es2 :: [Type]) Source #
es1 is a subset of es2.
There is no reflexive instance for abstract es: use containsRefl or
weakenExceptionsWith when es1 and es2 are the same type variable.
Minimal complete definition
subset
class Elem e (es :: [Type]) Source #
Membership in a type-level list, backed by a value-level index.
Duplicate types in es are not supported: the incoherent tail instance
picks the first index, so prefer (or a duplicate-free list) at
the kind level.Nub es
Minimal complete definition
elemIx
Instances
| Unsatisfiable (NotElemTypeError e ('[] :: [a]) :: ErrorMessage) => Elem e ('[] :: [Type]) Source # | |
Defined in Control.Monad.CheckedExcept | |
| Elem e (e ': es) Source # | |
Defined in Control.Monad.CheckedExcept | |
| Elem e es => Elem e (x ': es) Source # | |
Defined in Control.Monad.CheckedExcept | |
type family NonEmpty (xs :: [a]) where ... Source #
Equations
| NonEmpty ('[] :: [a]) = TypeError ('Text "type level list must be non-empty") :: Constraint | |
| NonEmpty (_1 :: [a]) = () |
type NotElemTypeError (x :: t) (xs :: t1) = TypeError (('ShowType x ':<>: 'Text " is not a member of ") ':<>: 'ShowType xs) :: k Source #