Copyright | (C) 2018 Ryan Scott |
---|---|
License | BSD-style (see LICENSE) |
Maintainer | Ryan Scott |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | GHC2021 |
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 :: forall {k} (err :: PErrorMessage). HasCallStack => Sing err -> Sing (TypeError err :: k)
- typeError :: HasCallStack => ErrorMessage -> a
- data ErrorMessage' s
- = Text s
- | 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 (a :: PErrorMessage) where
- SText :: forall (t :: Symbol). Sing t -> SErrorMessage ('Text t)
- SShowType :: forall {k} (ty :: k). Sing ty -> SErrorMessage ('ShowType ty :: ErrorMessage' Symbol)
- (:%<>:) :: forall (e1 :: ErrorMessage' Symbol) (e2 :: ErrorMessage' Symbol). Sing e1 -> Sing e2 -> SErrorMessage (e1 ':<>: e2)
- (:%$$:) :: forall (e1 :: ErrorMessage' Symbol) (e2 :: ErrorMessage' Symbol). Sing e1 -> Sing e2 -> SErrorMessage (e1 ':$$: e2)
- type family ConvertPErrorMessage (a :: PErrorMessage) :: ErrorMessage where ...
- showErrorMessage :: ErrorMessage -> String
- data TextSym0 (a :: TyFun s (ErrorMessage' s))
- type family TextSym1 (a6989586621680205225 :: s) :: ErrorMessage' s where ...
- data ShowTypeSym0 (a :: TyFun t (ErrorMessage' s))
- type family ShowTypeSym1 (a6989586621680205227 :: t) :: ErrorMessage' s where ...
- data (:<>:@#@$) (a :: TyFun (ErrorMessage' s) (ErrorMessage' s ~> ErrorMessage' s))
- data (a6989586621680205229 :: ErrorMessage' s) :<>:@#@$$ (b :: TyFun (ErrorMessage' s) (ErrorMessage' s))
- type family (a6989586621680205229 :: ErrorMessage' s) :<>:@#@$$$ (a6989586621680205230 :: ErrorMessage' s) :: ErrorMessage' s where ...
- data (:$$:@#@$) (a :: TyFun (ErrorMessage' s) (ErrorMessage' s ~> ErrorMessage' s))
- data (a6989586621680205232 :: ErrorMessage' s) :$$:@#@$$ (b :: TyFun (ErrorMessage' s) (ErrorMessage' s))
- type family (a6989586621680205232 :: ErrorMessage' s) :$$:@#@$$$ (a6989586621680205233 :: ErrorMessage' s) :: ErrorMessage' s where ...
- data TypeErrorSym0 (a1 :: TyFun PErrorMessage a)
- type family TypeErrorSym1 (a6989586621680205235 :: PErrorMessage) :: a where ...
Documentation
type family TypeError (x :: PErrorMessage) :: a where ... Source #
TypeError x = TypeError (ConvertPErrorMessage x) :: a |
sTypeError :: forall {k} (err :: PErrorMessage). HasCallStack => Sing err -> Sing (TypeError err :: k) 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. |
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
type Sing Source # | |
Defined in Data.Semigroup.Singletons.Internal.Wrappers | |
type Sing Source # | |
Defined in Data.Semigroup.Singletons.Internal.Wrappers | |
type Sing Source # | |
Defined in Data.Singletons.Base.Instances | |
type Sing Source # | |
Defined in GHC.TypeLits.Singletons.Internal | |
type Sing Source # | |
Defined in Data.Singletons.Base.Instances | |
type Sing Source # | |
Defined in Data.Singletons.Base.TypeError | |
type Sing Source # | |
Defined in Data.Singletons.Base.Instances | |
type Sing Source # | |
Defined in Data.Singletons.Base.Instances | |
type Sing Source # | |
Defined in GHC.TypeLits.Singletons.Internal | |
type Sing Source # | |
Defined in GHC.TypeLits.Singletons.Internal | |
type Sing Source # | |
Defined in Data.Singletons.Base.Instances | |
type Sing Source # | |
Defined in Data.Monoid.Singletons | |
type Sing Source # | |
Defined in Data.Monoid.Singletons | |
type Sing Source # | |
Defined in Data.Ord.Singletons | |
type Sing Source # | |
Defined in Data.Semigroup.Singletons.Internal.Wrappers | |
type Sing Source # | |
Defined in Data.Semigroup.Singletons.Internal.Wrappers | |
type Sing Source # | |
Defined in Data.Semigroup.Singletons.Internal.Wrappers | |
type Sing Source # | |
Defined in Data.Semigroup.Singletons.Internal.Wrappers | |
type Sing Source # | |
Defined in Data.Semigroup.Singletons.Internal.Wrappers | |
type Sing Source # | |
Defined in Data.Semigroup.Singletons.Internal.Wrappers | |
type Sing Source # | |
Defined in Data.Semigroup.Singletons.Internal.Wrappers | |
type Sing Source # | |
Defined in Data.Semigroup.Singletons.Internal.Wrappers | |
type Sing Source # | |
Defined in Data.Singletons.Base.Instances | |
type Sing Source # | |
Defined in Data.Singletons.Base.Instances | |
type Sing Source # | A choice of singleton for the kind Conceivably, one could generalize this instance to `Sing @k` for
any kind We cannot produce explicit singleton values for everything in |
Defined in Data.Singletons.Base.TypeRepTYPE | |
type Sing Source # | |
Defined in Data.Singletons.Base.Instances | |
type Sing Source # | |
Defined in Data.Singletons.Base.Instances | |
type Sing Source # | |
Defined in Data.Proxy.Singletons | |
type Sing Source # | |
Defined in Data.Semigroup.Singletons | |
type Sing | |
Defined in Data.Singletons | |
type Sing | |
Defined in Data.Singletons | |
type Sing | |
Defined in Data.Singletons.Sigma | |
type Sing Source # | |
Defined in Data.Singletons.Base.Instances | |
type Sing Source # | |
Defined in Data.Functor.Const.Singletons | |
type Sing Source # | |
Defined in Data.Singletons.Base.Instances | |
type Sing Source # | |
Defined in Data.Functor.Product.Singletons | |
type Sing Source # | |
Defined in Data.Functor.Sum.Singletons | |
type Sing Source # | |
Defined in Data.Singletons.Base.Instances | |
type Sing Source # | |
Defined in Data.Functor.Compose.Singletons | |
type Sing Source # | |
Defined in Data.Singletons.Base.Instances | |
type Sing Source # | |
Defined in Data.Singletons.Base.Instances | |
type Sing Source # | |
Defined in Data.Singletons.Base.Instances |
data SErrorMessage (a :: PErrorMessage) where Source #
SText :: forall (t :: Symbol). Sing t -> SErrorMessage ('Text t) | |
SShowType :: forall {k} (ty :: k). Sing ty -> SErrorMessage ('ShowType ty :: ErrorMessage' Symbol) | |
(:%<>:) :: forall (e1 :: ErrorMessage' Symbol) (e2 :: ErrorMessage' Symbol). Sing e1 -> Sing e2 -> SErrorMessage (e1 ':<>: e2) infixl 6 | |
(:%$$:) :: forall (e1 :: ErrorMessage' Symbol) (e2 :: ErrorMessage' Symbol). 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 :: ErrorMessage' Symbol) = '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 (a :: TyFun s (ErrorMessage' s)) 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) (a6989586621680205225 :: s) Source # | |
Defined in Data.Singletons.Base.TypeError |
type family TextSym1 (a6989586621680205225 :: s) :: ErrorMessage' s where ... Source #
data ShowTypeSym0 (a :: TyFun t (ErrorMessage' s)) Source #
Instances
SingI (ShowTypeSym0 :: TyFun t (ErrorMessage' Symbol) -> Type) Source # | |
Defined in Data.Singletons.Base.TypeError sing :: Sing (ShowTypeSym0 :: TyFun t (ErrorMessage' Symbol) -> Type) # | |
SuppressUnusedWarnings (ShowTypeSym0 :: TyFun t (ErrorMessage' s) -> Type) Source # | |
Defined in Data.Singletons.Base.TypeError suppressUnusedWarnings :: () # | |
type Apply (ShowTypeSym0 :: TyFun t (ErrorMessage' s) -> Type) (a6989586621680205227 :: t) Source # | |
Defined in Data.Singletons.Base.TypeError type Apply (ShowTypeSym0 :: TyFun t (ErrorMessage' s) -> Type) (a6989586621680205227 :: t) = 'ShowType a6989586621680205227 :: ErrorMessage' s |
type family ShowTypeSym1 (a6989586621680205227 :: t) :: ErrorMessage' s where ... Source #
ShowTypeSym1 (a6989586621680205227 :: t) = 'ShowType a6989586621680205227 :: ErrorMessage' s |
data (:<>:@#@$) (a :: TyFun (ErrorMessage' s) (ErrorMessage' s ~> ErrorMessage' s)) infixl 6 Source #
Instances
SingI ((:<>:@#@$) :: TyFun (ErrorMessage' Symbol) (ErrorMessage' Symbol ~> ErrorMessage' Symbol) -> Type) Source # | |
Defined in Data.Singletons.Base.TypeError sing :: Sing ((:<>:@#@$) :: TyFun (ErrorMessage' Symbol) (ErrorMessage' Symbol ~> ErrorMessage' Symbol) -> Type) # | |
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) (a6989586621680205229 :: ErrorMessage' s) Source # | |
Defined in Data.Singletons.Base.TypeError type Apply ((:<>:@#@$) :: TyFun (ErrorMessage' s) (ErrorMessage' s ~> ErrorMessage' s) -> Type) (a6989586621680205229 :: ErrorMessage' s) = (:<>:@#@$$) a6989586621680205229 |
data (a6989586621680205229 :: ErrorMessage' s) :<>:@#@$$ (b :: TyFun (ErrorMessage' s) (ErrorMessage' s)) infixl 6 Source #
Instances
SingI1 ((:<>:@#@$$) :: ErrorMessage' Symbol -> TyFun (ErrorMessage' Symbol) (ErrorMessage' Symbol) -> Type) Source # | |
Defined in Data.Singletons.Base.TypeError liftSing :: forall (x :: PErrorMessage). 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 ((:<>:@#@$$) a6989586621680205229 :: TyFun (ErrorMessage' s) (ErrorMessage' s) -> Type) Source # | |
Defined in Data.Singletons.Base.TypeError suppressUnusedWarnings :: () # | |
type Apply ((:<>:@#@$$) a6989586621680205229 :: TyFun (ErrorMessage' s) (ErrorMessage' s) -> Type) (a6989586621680205230 :: ErrorMessage' s) Source # | |
Defined in Data.Singletons.Base.TypeError type Apply ((:<>:@#@$$) a6989586621680205229 :: TyFun (ErrorMessage' s) (ErrorMessage' s) -> Type) (a6989586621680205230 :: ErrorMessage' s) = a6989586621680205229 ':<>: a6989586621680205230 |
type family (a6989586621680205229 :: ErrorMessage' s) :<>:@#@$$$ (a6989586621680205230 :: ErrorMessage' s) :: ErrorMessage' s where ... infixl 6 Source #
(a6989586621680205229 :: ErrorMessage' s) :<>:@#@$$$ (a6989586621680205230 :: ErrorMessage' s) = a6989586621680205229 ':<>: a6989586621680205230 |
data (:$$:@#@$) (a :: TyFun (ErrorMessage' s) (ErrorMessage' s ~> ErrorMessage' s)) infixl 5 Source #
Instances
SingI ((:$$:@#@$) :: TyFun (ErrorMessage' Symbol) (ErrorMessage' Symbol ~> ErrorMessage' Symbol) -> Type) Source # | |
Defined in Data.Singletons.Base.TypeError sing :: Sing ((:$$:@#@$) :: TyFun (ErrorMessage' Symbol) (ErrorMessage' Symbol ~> ErrorMessage' Symbol) -> Type) # | |
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) (a6989586621680205232 :: ErrorMessage' s) Source # | |
Defined in Data.Singletons.Base.TypeError type Apply ((:$$:@#@$) :: TyFun (ErrorMessage' s) (ErrorMessage' s ~> ErrorMessage' s) -> Type) (a6989586621680205232 :: ErrorMessage' s) = (:$$:@#@$$) a6989586621680205232 |
data (a6989586621680205232 :: ErrorMessage' s) :$$:@#@$$ (b :: TyFun (ErrorMessage' s) (ErrorMessage' s)) infixl 5 Source #
Instances
SingI1 ((:$$:@#@$$) :: ErrorMessage' Symbol -> TyFun (ErrorMessage' Symbol) (ErrorMessage' Symbol) -> Type) Source # | |
Defined in Data.Singletons.Base.TypeError liftSing :: forall (x :: PErrorMessage). 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 ((:$$:@#@$$) a6989586621680205232 :: TyFun (ErrorMessage' s) (ErrorMessage' s) -> Type) Source # | |
Defined in Data.Singletons.Base.TypeError suppressUnusedWarnings :: () # | |
type Apply ((:$$:@#@$$) a6989586621680205232 :: TyFun (ErrorMessage' s) (ErrorMessage' s) -> Type) (a6989586621680205233 :: ErrorMessage' s) Source # | |
Defined in Data.Singletons.Base.TypeError type Apply ((:$$:@#@$$) a6989586621680205232 :: TyFun (ErrorMessage' s) (ErrorMessage' s) -> Type) (a6989586621680205233 :: ErrorMessage' s) = a6989586621680205232 ':$$: a6989586621680205233 |
type family (a6989586621680205232 :: ErrorMessage' s) :$$:@#@$$$ (a6989586621680205233 :: ErrorMessage' s) :: ErrorMessage' s where ... infixl 5 Source #
(a6989586621680205232 :: ErrorMessage' s) :$$:@#@$$$ (a6989586621680205233 :: ErrorMessage' s) = a6989586621680205232 ':$$: a6989586621680205233 |
data TypeErrorSym0 (a1 :: TyFun PErrorMessage a) Source #
Instances
SingI (TypeErrorSym0 :: TyFun PErrorMessage a -> Type) Source # | |
Defined in Data.Singletons.Base.TypeError sing :: Sing (TypeErrorSym0 :: TyFun PErrorMessage a -> Type) # | |
SuppressUnusedWarnings (TypeErrorSym0 :: TyFun PErrorMessage a -> Type) Source # | |
Defined in Data.Singletons.Base.TypeError suppressUnusedWarnings :: () # | |
type Apply (TypeErrorSym0 :: TyFun PErrorMessage k2 -> Type) (a6989586621680205235 :: PErrorMessage) Source # | |
Defined in Data.Singletons.Base.TypeError type Apply (TypeErrorSym0 :: TyFun PErrorMessage k2 -> Type) (a6989586621680205235 :: PErrorMessage) = TypeError a6989586621680205235 :: k2 |
type family TypeErrorSym1 (a6989586621680205235 :: PErrorMessage) :: a where ... Source #
TypeErrorSym1 a6989586621680205235 = TypeError a6989586621680205235 :: a |