Copyright | (C) 2018 Ryan Scott |
---|---|
License | BSD-style (see LICENSE) |
Maintainer | Ryan Scott |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
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.TypeError at the same time, as many of the definitons
in the latter deliberately clash with the former.
Synopsis
- type family TypeError (a :: PErrorMessage) :: b 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 :: forall (s6989586621681331131 :: Type). (~>) s6989586621681331131 (ErrorMessage' (s6989586621681331131 :: Type))
- type TextSym1 (t6989586621681331875 :: s6989586621681331131) = 'Text t6989586621681331875
- data ShowTypeSym0 :: forall t6989586621681331132 (s6989586621681331131 :: Type). (~>) t6989586621681331132 (ErrorMessage' (s6989586621681331131 :: Type))
- type ShowTypeSym1 (t6989586621681331877 :: t6989586621681331132) = 'ShowType t6989586621681331877
- data (:<>:@#@$) :: forall (s6989586621681331131 :: Type). (~>) (ErrorMessage' s6989586621681331131) ((~>) (ErrorMessage' s6989586621681331131) (ErrorMessage' (s6989586621681331131 :: Type)))
- data (:<>:@#@$$) (t6989586621681331879 :: ErrorMessage' (s6989586621681331131 :: Type)) :: (~>) (ErrorMessage' s6989586621681331131) (ErrorMessage' (s6989586621681331131 :: Type))
- type (:<>:@#@$$$) (t6989586621681331879 :: ErrorMessage' s6989586621681331131) (t6989586621681331880 :: ErrorMessage' s6989586621681331131) = '(:<>:) t6989586621681331879 t6989586621681331880
- data (:$$:@#@$) :: forall (s6989586621681331131 :: Type). (~>) (ErrorMessage' s6989586621681331131) ((~>) (ErrorMessage' s6989586621681331131) (ErrorMessage' (s6989586621681331131 :: Type)))
- data (:$$:@#@$$) (t6989586621681331883 :: ErrorMessage' (s6989586621681331131 :: Type)) :: (~>) (ErrorMessage' s6989586621681331131) (ErrorMessage' (s6989586621681331131 :: Type))
- type (:$$:@#@$$$) (t6989586621681331883 :: ErrorMessage' s6989586621681331131) (t6989586621681331884 :: ErrorMessage' s6989586621681331131) = '(:$$:) t6989586621681331883 t6989586621681331884
- data TypeErrorSym0 :: forall b6989586621681331115. (~>) PErrorMessage b6989586621681331115
- type TypeErrorSym1 (a6989586621681331116 :: PErrorMessage) = TypeError a6989586621681331116
Documentation
type family TypeError (a :: PErrorMessage) :: b where ... Source #
TypeError a = TypeError (ConvertPErrorMessage a) |
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 Source #
The singleton kind-indexed type family.
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 :: forall (s6989586621681331131 :: Type). (~>) s6989586621681331131 (ErrorMessage' (s6989586621681331131 :: Type)) Source #
Instances
SingI (TextSym0 :: TyFun Symbol (ErrorMessage' Symbol) -> Type) Source # | |
SuppressUnusedWarnings (TextSym0 :: TyFun s6989586621681331131 (ErrorMessage' s6989586621681331131) -> Type) Source # | |
Defined in Data.Singletons.TypeError suppressUnusedWarnings :: () Source # | |
type Apply (TextSym0 :: TyFun s (ErrorMessage' s) -> Type) (t6989586621681331875 :: s) Source # | |
Defined in Data.Singletons.TypeError |
data ShowTypeSym0 :: forall t6989586621681331132 (s6989586621681331131 :: Type). (~>) t6989586621681331132 (ErrorMessage' (s6989586621681331131 :: Type)) Source #
Instances
SingI (ShowTypeSym0 :: TyFun t (ErrorMessage' Symbol) -> Type) Source # | |
Defined in Data.Singletons.TypeError sing :: Sing ShowTypeSym0 Source # | |
SuppressUnusedWarnings (ShowTypeSym0 :: TyFun t6989586621681331132 (ErrorMessage' s6989586621681331131) -> Type) Source # | |
Defined in Data.Singletons.TypeError suppressUnusedWarnings :: () Source # | |
type Apply (ShowTypeSym0 :: TyFun t (ErrorMessage' s6989586621681331131) -> Type) (t6989586621681331877 :: t) Source # | |
Defined in Data.Singletons.TypeError type Apply (ShowTypeSym0 :: TyFun t (ErrorMessage' s6989586621681331131) -> Type) (t6989586621681331877 :: t) = 'ShowType t6989586621681331877 :: ErrorMessage' s6989586621681331131 |
type ShowTypeSym1 (t6989586621681331877 :: t6989586621681331132) = 'ShowType t6989586621681331877 Source #
data (:<>:@#@$) :: forall (s6989586621681331131 :: Type). (~>) (ErrorMessage' s6989586621681331131) ((~>) (ErrorMessage' s6989586621681331131) (ErrorMessage' (s6989586621681331131 :: Type))) infixl 6 Source #
Instances
SingI ((:<>:@#@$) :: TyFun (ErrorMessage' Symbol) (ErrorMessage' Symbol ~> ErrorMessage' Symbol) -> Type) Source # | |
Defined in Data.Singletons.TypeError sing :: Sing (:<>:@#@$) Source # | |
SuppressUnusedWarnings ((:<>:@#@$) :: TyFun (ErrorMessage' s6989586621681331131) (ErrorMessage' s6989586621681331131 ~> ErrorMessage' s6989586621681331131) -> Type) Source # | |
Defined in Data.Singletons.TypeError suppressUnusedWarnings :: () Source # | |
type Apply ((:<>:@#@$) :: TyFun (ErrorMessage' s6989586621681331131) (ErrorMessage' s6989586621681331131 ~> ErrorMessage' s6989586621681331131) -> Type) (t6989586621681331879 :: ErrorMessage' s6989586621681331131) Source # | |
Defined in Data.Singletons.TypeError type Apply ((:<>:@#@$) :: TyFun (ErrorMessage' s6989586621681331131) (ErrorMessage' s6989586621681331131 ~> ErrorMessage' s6989586621681331131) -> Type) (t6989586621681331879 :: ErrorMessage' s6989586621681331131) = (:<>:@#@$$) t6989586621681331879 |
data (:<>:@#@$$) (t6989586621681331879 :: ErrorMessage' (s6989586621681331131 :: Type)) :: (~>) (ErrorMessage' s6989586621681331131) (ErrorMessage' (s6989586621681331131 :: Type)) infixl 6 Source #
Instances
SingI x => SingI ((:<>:@#@$$) x :: TyFun (ErrorMessage' Symbol) (ErrorMessage' Symbol) -> Type) Source # | |
Defined in Data.Singletons.TypeError sing :: Sing ((:<>:@#@$$) x) Source # | |
SuppressUnusedWarnings ((:<>:@#@$$) t6989586621681331879 :: TyFun (ErrorMessage' s6989586621681331131) (ErrorMessage' s6989586621681331131) -> Type) Source # | |
Defined in Data.Singletons.TypeError suppressUnusedWarnings :: () Source # | |
type Apply ((:<>:@#@$$) t6989586621681331879 :: TyFun (ErrorMessage' s) (ErrorMessage' s) -> Type) (t6989586621681331880 :: ErrorMessage' s) Source # | |
Defined in Data.Singletons.TypeError type Apply ((:<>:@#@$$) t6989586621681331879 :: TyFun (ErrorMessage' s) (ErrorMessage' s) -> Type) (t6989586621681331880 :: ErrorMessage' s) = t6989586621681331879 :<>: t6989586621681331880 |
type (:<>:@#@$$$) (t6989586621681331879 :: ErrorMessage' s6989586621681331131) (t6989586621681331880 :: ErrorMessage' s6989586621681331131) = '(:<>:) t6989586621681331879 t6989586621681331880 Source #
data (:$$:@#@$) :: forall (s6989586621681331131 :: Type). (~>) (ErrorMessage' s6989586621681331131) ((~>) (ErrorMessage' s6989586621681331131) (ErrorMessage' (s6989586621681331131 :: Type))) infixl 5 Source #
Instances
SingI ((:$$:@#@$) :: TyFun (ErrorMessage' Symbol) (ErrorMessage' Symbol ~> ErrorMessage' Symbol) -> Type) Source # | |
Defined in Data.Singletons.TypeError sing :: Sing (:$$:@#@$) Source # | |
SuppressUnusedWarnings ((:$$:@#@$) :: TyFun (ErrorMessage' s6989586621681331131) (ErrorMessage' s6989586621681331131 ~> ErrorMessage' s6989586621681331131) -> Type) Source # | |
Defined in Data.Singletons.TypeError suppressUnusedWarnings :: () Source # | |
type Apply ((:$$:@#@$) :: TyFun (ErrorMessage' s6989586621681331131) (ErrorMessage' s6989586621681331131 ~> ErrorMessage' s6989586621681331131) -> Type) (t6989586621681331883 :: ErrorMessage' s6989586621681331131) Source # | |
Defined in Data.Singletons.TypeError type Apply ((:$$:@#@$) :: TyFun (ErrorMessage' s6989586621681331131) (ErrorMessage' s6989586621681331131 ~> ErrorMessage' s6989586621681331131) -> Type) (t6989586621681331883 :: ErrorMessage' s6989586621681331131) = (:$$:@#@$$) t6989586621681331883 |
data (:$$:@#@$$) (t6989586621681331883 :: ErrorMessage' (s6989586621681331131 :: Type)) :: (~>) (ErrorMessage' s6989586621681331131) (ErrorMessage' (s6989586621681331131 :: Type)) infixl 5 Source #
Instances
SingI x => SingI ((:$$:@#@$$) x :: TyFun (ErrorMessage' Symbol) (ErrorMessage' Symbol) -> Type) Source # | |
Defined in Data.Singletons.TypeError sing :: Sing ((:$$:@#@$$) x) Source # | |
SuppressUnusedWarnings ((:$$:@#@$$) t6989586621681331883 :: TyFun (ErrorMessage' s6989586621681331131) (ErrorMessage' s6989586621681331131) -> Type) Source # | |
Defined in Data.Singletons.TypeError suppressUnusedWarnings :: () Source # | |
type Apply ((:$$:@#@$$) t6989586621681331883 :: TyFun (ErrorMessage' s) (ErrorMessage' s) -> Type) (t6989586621681331884 :: ErrorMessage' s) Source # | |
Defined in Data.Singletons.TypeError type Apply ((:$$:@#@$$) t6989586621681331883 :: TyFun (ErrorMessage' s) (ErrorMessage' s) -> Type) (t6989586621681331884 :: ErrorMessage' s) = t6989586621681331883 :$$: t6989586621681331884 |
type (:$$:@#@$$$) (t6989586621681331883 :: ErrorMessage' s6989586621681331131) (t6989586621681331884 :: ErrorMessage' s6989586621681331131) = '(:$$:) t6989586621681331883 t6989586621681331884 Source #
data TypeErrorSym0 :: forall b6989586621681331115. (~>) PErrorMessage b6989586621681331115 Source #
Instances
SingI (TypeErrorSym0 :: TyFun PErrorMessage b6989586621681331115 -> Type) Source # | |
Defined in Data.Singletons.TypeError sing :: Sing TypeErrorSym0 Source # | |
SuppressUnusedWarnings (TypeErrorSym0 :: TyFun PErrorMessage b6989586621681331115 -> Type) Source # | |
Defined in Data.Singletons.TypeError suppressUnusedWarnings :: () Source # | |
type Apply (TypeErrorSym0 :: TyFun PErrorMessage k2 -> Type) (a6989586621681331116 :: PErrorMessage) Source # | |
Defined in Data.Singletons.TypeError type Apply (TypeErrorSym0 :: TyFun PErrorMessage k2 -> Type) (a6989586621681331116 :: PErrorMessage) = TypeError a6989586621681331116 :: k2 |
type TypeErrorSym1 (a6989586621681331116 :: PErrorMessage) = TypeError a6989586621681331116 Source #