Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- type (:</>:) a b = (a :<>: ErrMsg " ") :<>: b
- type Between' s a = Between s s a
- type Between l r a = (ErrMsg l :<>: a) :<>: ErrMsg r
- type Parensed a = Between "(" ")" a
- type Ticked a = Between' "`" a
- type Sentence a = a :<>: ErrMsg "."
- type TypeAssert ok = TypeErrorIf ok (ErrMsg "Assertion failed.")
- class TypeErrorIf (ok :: Bool) (err :: ErrorMessage)
- type ErrMsg = Text
- type family TypeError (a :: ErrorMessage) :: b where ...
- data ErrorMessage where
- ShowType :: forall t. t -> ErrorMessage
- (:<>:) :: forall. ErrorMessage -> ErrorMessage -> ErrorMessage
- (:$$:) :: forall. ErrorMessage -> ErrorMessage -> ErrorMessage
Documentation
type TypeAssert ok = TypeErrorIf ok (ErrMsg "Assertion failed.") Source #
class TypeErrorIf (ok :: Bool) (err :: ErrorMessage) Source #
Instances
(TypeError err :: Constraint) => TypeErrorIf False err Source # | |
Defined in Type.Error | |
TypeErrorIf True err Source # | |
Defined in Type.Error |
type family TypeError (a :: ErrorMessage) :: b where ... #
The type-level 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 non-existent 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 right-hand side of a type-level 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: base-4.9.0.0
data ErrorMessage where #
A description of a custom type error.
ShowType :: forall t. t -> ErrorMessage | Pretty print the type.
|
(:<>:) :: forall. ErrorMessage -> ErrorMessage -> ErrorMessage infixl 6 | Put two pieces of error message next to each other. |
(:$$:) :: forall. ErrorMessage -> ErrorMessage -> ErrorMessage infixl 5 | Stack two pieces of error message on top of each other. |