Defines the Throws
binary relationship between types.
- class (Private l, Exception e) => Throws e l
- data Caught e l
- class Exception e => UncaughtException e
- data NoExceptions
- data ParanoidMode
Documentation
class (Private l, Exception e) => Throws e l Source
Throws
is a type level binary relationship
used to model a list of exceptions.
Usually there is no need for the user
to add further instances to Throws
except
to encode subtyping.
As there is no way to automatically infer
the subcases of an exception, they have to be encoded
manually mirroring the hierarchy defined in the defined
Exception
instances.
For example,
the following instance encodes that MyFileNotFoundException
is
a subexception of MyIOException
:
instance Throws MyFileNotFoundException (Caught MyIOException l)
Throws
is not a transitive relation and every ancestor relation
must be explicitly encoded.
-- TopException -- | instance Throws MidException TopException -- | -- MidException instance Throws ChildException MidException -- | instance Throws ChildException TopException -- | -- ChildException
SomeException
is automatically
an ancestor of every other exception type.
UncaughtException e => Throws e NoExceptions | |
Exception e => Throws e (Caught SomeException l) |
|
Exception e => Throws e (Caught e l) | |
Throws e l => Throws e (Caught e' l) |
A type level witness of a exception handler.
Exception e => Throws e (Caught SomeException l) |
|
Exception e => Throws e (Caught e l) | |
Throws e l => Throws e (Caught e' l) | |
(Exception e, Monad m) => MonadCatch e (EMT (Caught e l) m) (EMT l m) | |
Private (Caught e l) |
class Exception e => UncaughtException e Source
Uncaught Exceptions model unchecked exceptions (a la RuntimeException in Java)
In order to declare an unchecked exception e
,
all that is needed is to make e
an instance of UncaughtException
data NoExceptions Source
Private NoExceptions | |
UncaughtException e => Throws e NoExceptions |
data ParanoidMode Source
Private ParanoidMode |