Copyright | (C) 2018 Ryan Scott |
---|---|
License | BSD-style (see LICENSE) |
Maintainer | Ryan Scott |
Stability | experimental |
Portability | non-portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Defines a drop-in replacement for TypeError
(from GHC.TypeLits)
that can be used at the value level as well. Since this is a drop-in
replacement, it is not recommended to import all of GHC.TypeLits
and Data.Singletons.Base.TypeError at the same time, as many of the
definitions in the latter deliberately clash with the former.
Synopsis
- type family TypeError (x :: PErrorMessage) :: a where ...
- sTypeError :: HasCallStack => Sing err -> Sing (TypeError err)
- typeError :: HasCallStack => ErrorMessage -> a
- data ErrorMessage' s
- = Text s
- | forall t. ShowType t
- | (ErrorMessage' s) :<>: (ErrorMessage' s)
- | (ErrorMessage' s) :$$: (ErrorMessage' s)
- type ErrorMessage = ErrorMessage' Text
- type PErrorMessage = ErrorMessage' Symbol
- type family Sing :: k -> Type
- data SErrorMessage :: PErrorMessage -> Type where
- SText :: Sing t -> SErrorMessage ('Text t)
- SShowType :: Sing ty -> SErrorMessage ('ShowType ty)
- (:%<>:) :: Sing e1 -> Sing e2 -> SErrorMessage (e1 :<>: e2)
- (:%$$:) :: Sing e1 -> Sing e2 -> SErrorMessage (e1 :$$: e2)
- type family ConvertPErrorMessage (a :: PErrorMessage) :: ErrorMessage where ...
- showErrorMessage :: ErrorMessage -> String
- data TextSym0 :: (~>) s (ErrorMessage' (s :: Type))
- type family TextSym1 (a6989586621679680814 :: s) :: ErrorMessage' (s :: Type) where ...
- data ShowTypeSym0 :: (~>) t (ErrorMessage' (s :: Type))
- type family ShowTypeSym1 (a6989586621679680816 :: t) :: ErrorMessage' (s :: Type) where ...
- data (:<>:@#@$) :: (~>) (ErrorMessage' s) ((~>) (ErrorMessage' s) (ErrorMessage' (s :: Type)))
- data (:<>:@#@$$) (a6989586621679680818 :: ErrorMessage' s) :: (~>) (ErrorMessage' s) (ErrorMessage' (s :: Type))
- type family (a6989586621679680818 :: ErrorMessage' s) :<>:@#@$$$ (a6989586621679680819 :: ErrorMessage' s) :: ErrorMessage' (s :: Type) where ...
- data (:$$:@#@$) :: (~>) (ErrorMessage' s) ((~>) (ErrorMessage' s) (ErrorMessage' (s :: Type)))
- data (:$$:@#@$$) (a6989586621679680821 :: ErrorMessage' s) :: (~>) (ErrorMessage' s) (ErrorMessage' (s :: Type))
- type family (a6989586621679680821 :: ErrorMessage' s) :$$:@#@$$$ (a6989586621679680822 :: ErrorMessage' s) :: ErrorMessage' (s :: Type) where ...
- data TypeErrorSym0 :: (~>) PErrorMessage a
- type family TypeErrorSym1 (a6989586621679680824 :: PErrorMessage) :: a where ...
Documentation
type family TypeError (x :: PErrorMessage) :: a where ... Source #
TypeError x = TypeError (ConvertPErrorMessage x) |
sTypeError :: HasCallStack => Sing err -> Sing (TypeError err) Source #
typeError :: HasCallStack => ErrorMessage -> a Source #
data ErrorMessage' s Source #
A description of a custom type error.
This is a variation on ErrorMessage
that is parameterized over what
text type is used in the Text
constructor. Instantiating it with
Text
gives you ErrorMessage
, and instantiating it with Symbol
gives you PErrorMessage
.
Text s | Show the text as is. |
forall t. ShowType t | Pretty print the type.
|
(ErrorMessage' s) :<>: (ErrorMessage' s) infixl 6 | Put two pieces of error message next to each other. |
(ErrorMessage' s) :$$: (ErrorMessage' s) infixl 5 | Stack two pieces of error message on top of each other. |
Instances
type ErrorMessage = ErrorMessage' Text Source #
A value-level ErrorMessage
` which uses Text
as its text type.
type PErrorMessage = ErrorMessage' Symbol Source #
A type-level ErrorMessage
` which uses Symbol
as its text kind.
type family Sing :: k -> Type #
Instances
data SErrorMessage :: PErrorMessage -> Type where Source #
SText :: Sing t -> SErrorMessage ('Text t) | |
SShowType :: Sing ty -> SErrorMessage ('ShowType ty) | |
(:%<>:) :: Sing e1 -> Sing e2 -> SErrorMessage (e1 :<>: e2) infixl 6 | |
(:%$$:) :: Sing e1 -> Sing e2 -> SErrorMessage (e1 :$$: e2) infixl 5 |
type family ConvertPErrorMessage (a :: PErrorMessage) :: ErrorMessage where ... Source #
Convert a PErrorMessage
to a ErrorMessage
from GHC.TypeLits.
ConvertPErrorMessage ('Text t) = 'Text t | |
ConvertPErrorMessage ('ShowType ty) = 'ShowType ty | |
ConvertPErrorMessage (e1 :<>: e2) = ConvertPErrorMessage e1 :<>: ConvertPErrorMessage e2 | |
ConvertPErrorMessage (e1 :$$: e2) = ConvertPErrorMessage e1 :$$: ConvertPErrorMessage e2 |
showErrorMessage :: ErrorMessage -> String Source #
Convert an ErrorMessage
into a human-readable String
.
Defunctionalization symbols
data TextSym0 :: (~>) s (ErrorMessage' (s :: Type)) Source #
Instances
SingI (TextSym0 :: TyFun Symbol (ErrorMessage' Symbol) -> Type) Source # | |
Defined in Data.Singletons.Base.TypeError | |
SuppressUnusedWarnings (TextSym0 :: TyFun s (ErrorMessage' s) -> Type) Source # | |
Defined in Data.Singletons.Base.TypeError suppressUnusedWarnings :: () # | |
type Apply (TextSym0 :: TyFun s (ErrorMessage' s) -> Type) (a6989586621679680814 :: s) Source # | |
Defined in Data.Singletons.Base.TypeError type Apply (TextSym0 :: TyFun s (ErrorMessage' s) -> Type) (a6989586621679680814 :: s) = 'Text a6989586621679680814 |
type family TextSym1 (a6989586621679680814 :: s) :: ErrorMessage' (s :: Type) where ... Source #
data ShowTypeSym0 :: (~>) t (ErrorMessage' (s :: Type)) Source #
Instances
SingI (ShowTypeSym0 :: TyFun t (ErrorMessage' Symbol) -> Type) Source # | |
Defined in Data.Singletons.Base.TypeError sing :: Sing ShowTypeSym0 | |
SuppressUnusedWarnings (ShowTypeSym0 :: TyFun t (ErrorMessage' s) -> Type) Source # | |
Defined in Data.Singletons.Base.TypeError suppressUnusedWarnings :: () # | |
type Apply (ShowTypeSym0 :: TyFun t (ErrorMessage' s) -> Type) (a6989586621679680816 :: t) Source # | |
Defined in Data.Singletons.Base.TypeError type Apply (ShowTypeSym0 :: TyFun t (ErrorMessage' s) -> Type) (a6989586621679680816 :: t) = 'ShowType a6989586621679680816 :: ErrorMessage' s |
type family ShowTypeSym1 (a6989586621679680816 :: t) :: ErrorMessage' (s :: Type) where ... Source #
ShowTypeSym1 a6989586621679680816 = 'ShowType a6989586621679680816 |
data (:<>:@#@$) :: (~>) (ErrorMessage' s) ((~>) (ErrorMessage' s) (ErrorMessage' (s :: Type))) infixl 6 Source #
Instances
SingI ((:<>:@#@$) :: TyFun (ErrorMessage' Symbol) (ErrorMessage' Symbol ~> ErrorMessage' Symbol) -> Type) Source # | |
Defined in Data.Singletons.Base.TypeError sing :: Sing (:<>:@#@$) | |
SuppressUnusedWarnings ((:<>:@#@$) :: TyFun (ErrorMessage' s) (ErrorMessage' s ~> ErrorMessage' s) -> Type) Source # | |
Defined in Data.Singletons.Base.TypeError suppressUnusedWarnings :: () # | |
type Apply ((:<>:@#@$) :: TyFun (ErrorMessage' s) (ErrorMessage' s ~> ErrorMessage' s) -> Type) (a6989586621679680818 :: ErrorMessage' s) Source # | |
Defined in Data.Singletons.Base.TypeError type Apply ((:<>:@#@$) :: TyFun (ErrorMessage' s) (ErrorMessage' s ~> ErrorMessage' s) -> Type) (a6989586621679680818 :: ErrorMessage' s) = (:<>:@#@$$) a6989586621679680818 |
data (:<>:@#@$$) (a6989586621679680818 :: ErrorMessage' s) :: (~>) (ErrorMessage' s) (ErrorMessage' (s :: Type)) infixl 6 Source #
Instances
SingI1 ((:<>:@#@$$) :: ErrorMessage' Symbol -> TyFun (ErrorMessage' Symbol) (ErrorMessage' Symbol) -> Type) Source # | |
Defined in Data.Singletons.Base.TypeError liftSing :: forall (x :: k1). Sing x -> Sing ((:<>:@#@$$) x) | |
SingI x => SingI ((:<>:@#@$$) x :: TyFun (ErrorMessage' Symbol) (ErrorMessage' Symbol) -> Type) Source # | |
Defined in Data.Singletons.Base.TypeError sing :: Sing ((:<>:@#@$$) x) | |
SuppressUnusedWarnings ((:<>:@#@$$) a6989586621679680818 :: TyFun (ErrorMessage' s) (ErrorMessage' s) -> Type) Source # | |
Defined in Data.Singletons.Base.TypeError suppressUnusedWarnings :: () # | |
type Apply ((:<>:@#@$$) a6989586621679680818 :: TyFun (ErrorMessage' s) (ErrorMessage' s) -> Type) (a6989586621679680819 :: ErrorMessage' s) Source # | |
Defined in Data.Singletons.Base.TypeError type Apply ((:<>:@#@$$) a6989586621679680818 :: TyFun (ErrorMessage' s) (ErrorMessage' s) -> Type) (a6989586621679680819 :: ErrorMessage' s) = a6989586621679680818 :<>: a6989586621679680819 |
type family (a6989586621679680818 :: ErrorMessage' s) :<>:@#@$$$ (a6989586621679680819 :: ErrorMessage' s) :: ErrorMessage' (s :: Type) where ... infixl 6 Source #
a6989586621679680818 :<>:@#@$$$ a6989586621679680819 = '(:<>:) a6989586621679680818 a6989586621679680819 |
data (:$$:@#@$) :: (~>) (ErrorMessage' s) ((~>) (ErrorMessage' s) (ErrorMessage' (s :: Type))) infixl 5 Source #
Instances
SingI ((:$$:@#@$) :: TyFun (ErrorMessage' Symbol) (ErrorMessage' Symbol ~> ErrorMessage' Symbol) -> Type) Source # | |
Defined in Data.Singletons.Base.TypeError sing :: Sing (:$$:@#@$) | |
SuppressUnusedWarnings ((:$$:@#@$) :: TyFun (ErrorMessage' s) (ErrorMessage' s ~> ErrorMessage' s) -> Type) Source # | |
Defined in Data.Singletons.Base.TypeError suppressUnusedWarnings :: () # | |
type Apply ((:$$:@#@$) :: TyFun (ErrorMessage' s) (ErrorMessage' s ~> ErrorMessage' s) -> Type) (a6989586621679680821 :: ErrorMessage' s) Source # | |
Defined in Data.Singletons.Base.TypeError type Apply ((:$$:@#@$) :: TyFun (ErrorMessage' s) (ErrorMessage' s ~> ErrorMessage' s) -> Type) (a6989586621679680821 :: ErrorMessage' s) = (:$$:@#@$$) a6989586621679680821 |
data (:$$:@#@$$) (a6989586621679680821 :: ErrorMessage' s) :: (~>) (ErrorMessage' s) (ErrorMessage' (s :: Type)) infixl 5 Source #
Instances
SingI1 ((:$$:@#@$$) :: ErrorMessage' Symbol -> TyFun (ErrorMessage' Symbol) (ErrorMessage' Symbol) -> Type) Source # | |
Defined in Data.Singletons.Base.TypeError liftSing :: forall (x :: k1). Sing x -> Sing ((:$$:@#@$$) x) | |
SingI x => SingI ((:$$:@#@$$) x :: TyFun (ErrorMessage' Symbol) (ErrorMessage' Symbol) -> Type) Source # | |
Defined in Data.Singletons.Base.TypeError sing :: Sing ((:$$:@#@$$) x) | |
SuppressUnusedWarnings ((:$$:@#@$$) a6989586621679680821 :: TyFun (ErrorMessage' s) (ErrorMessage' s) -> Type) Source # | |
Defined in Data.Singletons.Base.TypeError suppressUnusedWarnings :: () # | |
type Apply ((:$$:@#@$$) a6989586621679680821 :: TyFun (ErrorMessage' s) (ErrorMessage' s) -> Type) (a6989586621679680822 :: ErrorMessage' s) Source # | |
Defined in Data.Singletons.Base.TypeError type Apply ((:$$:@#@$$) a6989586621679680821 :: TyFun (ErrorMessage' s) (ErrorMessage' s) -> Type) (a6989586621679680822 :: ErrorMessage' s) = a6989586621679680821 :$$: a6989586621679680822 |
type family (a6989586621679680821 :: ErrorMessage' s) :$$:@#@$$$ (a6989586621679680822 :: ErrorMessage' s) :: ErrorMessage' (s :: Type) where ... infixl 5 Source #
a6989586621679680821 :$$:@#@$$$ a6989586621679680822 = '(:$$:) a6989586621679680821 a6989586621679680822 |
data TypeErrorSym0 :: (~>) PErrorMessage a Source #
Instances
SingI (TypeErrorSym0 :: TyFun PErrorMessage a -> Type) Source # | |
Defined in Data.Singletons.Base.TypeError | |
SuppressUnusedWarnings (TypeErrorSym0 :: TyFun PErrorMessage a -> Type) Source # | |
Defined in Data.Singletons.Base.TypeError suppressUnusedWarnings :: () # | |
type Apply (TypeErrorSym0 :: TyFun PErrorMessage k2 -> Type) (a6989586621679680824 :: PErrorMessage) Source # | |
Defined in Data.Singletons.Base.TypeError type Apply (TypeErrorSym0 :: TyFun PErrorMessage k2 -> Type) (a6989586621679680824 :: PErrorMessage) = TypeError a6989586621679680824 :: k2 |
type family TypeErrorSym1 (a6989586621679680824 :: PErrorMessage) :: a where ... Source #
TypeErrorSym1 a6989586621679680824 = TypeError a6989586621679680824 |