Safe Haskell  Trustworthy 

Language  Haskell2010 
This module exports the TypeError family, which is used to provide custom type errors, and the ErrorMessage kind used to define these custom error messages. This is a typelevel analogue to the term level error function.
Since: base4.16.0.0
Synopsis
 data ErrorMessage
 = Text Symbol
  forall t. ShowType t
  ErrorMessage :<>: ErrorMessage
  ErrorMessage :$$: ErrorMessage
 type family TypeError (a :: ErrorMessage) :: b where ...
 type family Assert check errMsg where ...
Documentation
data ErrorMessage Source #
A description of a custom type error.
Text Symbol  Show the text as is. 
forall t. ShowType t  Pretty print the type.

ErrorMessage :<>: ErrorMessage infixl 6  Put two pieces of error message next to each other. 
ErrorMessage :$$: ErrorMessage infixl 5  Stack two pieces of error message on top of each other. 
type family TypeError (a :: ErrorMessage) :: b where ... Source #
The typelevel equivalent of error
.
The polymorphic kind of this type allows it to be used in several settings. For instance, it can be used as a constraint, e.g. to provide a better error message for a nonexistent instance,
 in a context
instance TypeError (Text "Cannot Show
functions." :$$:
Text "Perhaps there is a missing argument?")
=> Show (a > b) where
showsPrec = error "unreachable"
It can also be placed on the righthand side of a typelevel function to provide an error for an invalid case,
type family ByteSize x where ByteSize Word16 = 2 ByteSize Word8 = 1 ByteSize a = TypeError (Text "The type " :<>: ShowType a :<>: Text " is not exportable.")
Since: base4.9.0.0
type family Assert check errMsg where ... Source #
A typelevel assert function.
If the first argument evaluates to true, then the empty constraint is
returned, otherwise the second argument (which is intended to be something
which reduces to TypeError
is used).
For example, given some type level predicate P' :: Type > Bool
, it is
possible to write the type synonym
type P a = Assert (P' a) (NotPError a)
where NotPError
reduces to a TypeError
which is reported if the
assertion fails.
Since: base4.16.0.0