singletons-2.7: A framework for generating singleton types
Copyright(C) 2018 Ryan Scott
LicenseBSD-style (see LICENSE)
MaintainerRyan Scott
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Data.Singletons.TypeError

Description

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

Documentation

type family TypeError a where ... Source #

A drop-in replacement for TypeError. This also exists at the value-level as typeError.

sTypeError :: HasCallStack => Sing err -> Sing (TypeError err) Source #

The singleton for typeError.

Note that this is not quite as expressive as TypeError, as it is unable to handle ShowType constructors at all.

typeError :: HasCallStack => ErrorMessage -> a Source #

The value-level counterpart to TypeError.

Note that this is not quite as expressive as TypeError, as it is unable to print the contents of ShowType constructors (it will simply print "<type>" in their place).

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.

Constructors

Text s

Show the text as is.

forall t. ShowType t

Pretty print the type. ShowType :: k -> ErrorMessage

(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

Instances details
SingKind PErrorMessage Source # 
Instance details

Defined in Data.Singletons.TypeError

Associated Types

type Demote PErrorMessage = (r :: Type) Source #

SingI t => SingI ('Text t :: ErrorMessage' Symbol) Source # 
Instance details

Defined in Data.Singletons.TypeError

Methods

sing :: Sing ('Text t) Source #

SingI ty => SingI ('ShowType ty :: ErrorMessage' Symbol) Source # 
Instance details

Defined in Data.Singletons.TypeError

Methods

sing :: Sing ('ShowType ty) Source #

(SingI e1, SingI e2) => SingI (e1 :<>: e2 :: ErrorMessage' Symbol) Source # 
Instance details

Defined in Data.Singletons.TypeError

Methods

sing :: Sing (e1 :<>: e2) Source #

(SingI e1, SingI e2) => SingI (e1 :$$: e2 :: ErrorMessage' Symbol) Source # 
Instance details

Defined in Data.Singletons.TypeError

Methods

sing :: Sing (e1 :$$: e2) Source #

SingI (TypeErrorSym0 :: TyFun PErrorMessage a -> Type) Source # 
Instance details

Defined in Data.Singletons.TypeError

SingI (TextSym0 :: TyFun Symbol (ErrorMessage' Symbol) -> Type) Source # 
Instance details

Defined in Data.Singletons.TypeError

SingI ((:$$:@#@$) :: TyFun (ErrorMessage' Symbol) (ErrorMessage' Symbol ~> ErrorMessage' Symbol) -> Type) Source # 
Instance details

Defined in Data.Singletons.TypeError

SingI ((:<>:@#@$) :: TyFun (ErrorMessage' Symbol) (ErrorMessage' Symbol ~> ErrorMessage' Symbol) -> Type) Source # 
Instance details

Defined in Data.Singletons.TypeError

SuppressUnusedWarnings (TextSym0 :: TyFun s (ErrorMessage' s) -> Type) Source # 
Instance details

Defined in Data.Singletons.TypeError

SuppressUnusedWarnings (TypeErrorSym0 :: TyFun PErrorMessage a -> Type) Source # 
Instance details

Defined in Data.Singletons.TypeError

SuppressUnusedWarnings ((:<>:@#@$) :: TyFun (ErrorMessage' s) (ErrorMessage' s ~> ErrorMessage' s) -> Type) Source # 
Instance details

Defined in Data.Singletons.TypeError

SuppressUnusedWarnings ((:$$:@#@$) :: TyFun (ErrorMessage' s) (ErrorMessage' s ~> ErrorMessage' s) -> Type) Source # 
Instance details

Defined in Data.Singletons.TypeError

SingI (ShowTypeSym0 :: TyFun t (ErrorMessage' Symbol) -> Type) Source # 
Instance details

Defined in Data.Singletons.TypeError

SingI x => SingI ((:$$:@#@$$) x :: TyFun (ErrorMessage' Symbol) (ErrorMessage' Symbol) -> Type) Source # 
Instance details

Defined in Data.Singletons.TypeError

Methods

sing :: Sing ((:$$:@#@$$) x) Source #

SingI x => SingI ((:<>:@#@$$) x :: TyFun (ErrorMessage' Symbol) (ErrorMessage' Symbol) -> Type) Source # 
Instance details

Defined in Data.Singletons.TypeError

Methods

sing :: Sing ((:<>:@#@$$) x) Source #

SuppressUnusedWarnings (ShowTypeSym0 :: TyFun t (ErrorMessage' s) -> Type) Source # 
Instance details

Defined in Data.Singletons.TypeError

SuppressUnusedWarnings ((:<>:@#@$$) a6989586621681349587 :: TyFun (ErrorMessage' s) (ErrorMessage' s) -> Type) Source # 
Instance details

Defined in Data.Singletons.TypeError

SuppressUnusedWarnings ((:$$:@#@$$) a6989586621681349590 :: TyFun (ErrorMessage' s) (ErrorMessage' s) -> Type) Source # 
Instance details

Defined in Data.Singletons.TypeError

type Demote PErrorMessage Source # 
Instance details

Defined in Data.Singletons.TypeError

type Sing Source # 
Instance details

Defined in Data.Singletons.TypeError

type Apply (TypeErrorSym0 :: TyFun PErrorMessage k2 -> Type) (a6989586621681349593 :: PErrorMessage) Source # 
Instance details

Defined in Data.Singletons.TypeError

type Apply (TypeErrorSym0 :: TyFun PErrorMessage k2 -> Type) (a6989586621681349593 :: PErrorMessage) = TypeErrorSym1 a6989586621681349593 :: k2
type Apply (TextSym0 :: TyFun s (ErrorMessage' s) -> Type) (a6989586621681349583 :: s) Source # 
Instance details

Defined in Data.Singletons.TypeError

type Apply (TextSym0 :: TyFun s (ErrorMessage' s) -> Type) (a6989586621681349583 :: s) = TextSym1 a6989586621681349583
type Apply (ShowTypeSym0 :: TyFun t (ErrorMessage' s) -> Type) (a6989586621681349585 :: t) Source # 
Instance details

Defined in Data.Singletons.TypeError

type Apply (ShowTypeSym0 :: TyFun t (ErrorMessage' s) -> Type) (a6989586621681349585 :: t) = ShowTypeSym1 a6989586621681349585 :: ErrorMessage' s
type Apply ((:<>:@#@$$) a6989586621681349587 :: TyFun (ErrorMessage' s) (ErrorMessage' s) -> Type) (a6989586621681349588 :: ErrorMessage' s) Source # 
Instance details

Defined in Data.Singletons.TypeError

type Apply ((:<>:@#@$$) a6989586621681349587 :: TyFun (ErrorMessage' s) (ErrorMessage' s) -> Type) (a6989586621681349588 :: ErrorMessage' s) = a6989586621681349587 :<>:@#@$$$ a6989586621681349588
type Apply ((:$$:@#@$$) a6989586621681349590 :: TyFun (ErrorMessage' s) (ErrorMessage' s) -> Type) (a6989586621681349591 :: ErrorMessage' s) Source # 
Instance details

Defined in Data.Singletons.TypeError

type Apply ((:$$:@#@$$) a6989586621681349590 :: TyFun (ErrorMessage' s) (ErrorMessage' s) -> Type) (a6989586621681349591 :: ErrorMessage' s) = a6989586621681349590 :$$:@#@$$$ a6989586621681349591
type Apply ((:<>:@#@$) :: TyFun (ErrorMessage' s) (ErrorMessage' s ~> ErrorMessage' s) -> Type) (a6989586621681349587 :: ErrorMessage' s) Source # 
Instance details

Defined in Data.Singletons.TypeError

type Apply ((:<>:@#@$) :: TyFun (ErrorMessage' s) (ErrorMessage' s ~> ErrorMessage' s) -> Type) (a6989586621681349587 :: ErrorMessage' s) = (:<>:@#@$$) a6989586621681349587
type Apply ((:$$:@#@$) :: TyFun (ErrorMessage' s) (ErrorMessage' s ~> ErrorMessage' s) -> Type) (a6989586621681349590 :: ErrorMessage' s) Source # 
Instance details

Defined in Data.Singletons.TypeError

type Apply ((:$$:@#@$) :: TyFun (ErrorMessage' s) (ErrorMessage' s ~> ErrorMessage' s) -> Type) (a6989586621681349590 :: ErrorMessage' s) = (:$$:@#@$$) a6989586621681349590

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 Source #

The singleton kind-indexed type family.

Instances

Instances details
type Sing Source # 
Instance details

Defined in Data.Singletons.Prelude.Instances

type Sing = SBool
type Sing Source # 
Instance details

Defined in Data.Singletons.Prelude.Instances

type Sing Source # 
Instance details

Defined in Data.Singletons.TypeLits.Internal

type Sing = SNat
type Sing Source # 
Instance details

Defined in Data.Singletons.TypeLits.Internal

type Sing = SSymbol
type Sing Source # 
Instance details

Defined in Data.Singletons.Prelude.Instances

type Sing = STuple0
type Sing Source # 
Instance details

Defined in Data.Singletons.Prelude.Instances

type Sing = SVoid
type Sing Source # 
Instance details

Defined in Data.Singletons.Prelude.Semigroup.Internal

type Sing = SAll
type Sing Source # 
Instance details

Defined in Data.Singletons.Prelude.Semigroup.Internal

type Sing = SAny
type Sing Source # 
Instance details

Defined in Data.Singletons.TypeError

type Sing Source # 
Instance details

Defined in Data.Singletons.Prelude.Instances

type Sing = SList :: [a] -> Type
type Sing Source # 
Instance details

Defined in Data.Singletons.Prelude.Instances

type Sing = SMaybe :: Maybe a -> Type
type Sing Source #

A choice of singleton for the kind TYPE rep (for some RuntimeRep rep), an instantiation of which is the famous kind Type.

Conceivably, one could generalize this instance to `Sing @k` for any kind k, and remove all other Sing instances. We don't adopt this design, however, since it is far more convenient in practice to work with explicit singleton values than TypeReps (for instance, TypeReps are more difficult to pattern match on, and require extra runtime checks).

We cannot produce explicit singleton values for everything in TYPE rep, however, since it is an open kind, so we reach for TypeRep in this one particular case.

Instance details

Defined in Data.Singletons.TypeRepTYPE

type Sing = TypeRep :: TYPE rep -> Type
type Sing Source # 
Instance details

Defined in Data.Singletons.Prelude.Semigroup.Internal

type Sing = SMin :: Min a -> Type
type Sing Source # 
Instance details

Defined in Data.Singletons.Prelude.Semigroup.Internal

type Sing = SMax :: Max a -> Type
type Sing Source # 
Instance details

Defined in Data.Singletons.Prelude.Semigroup.Internal

type Sing = SFirst :: First a -> Type
type Sing Source # 
Instance details

Defined in Data.Singletons.Prelude.Semigroup.Internal

type Sing = SLast :: Last a -> Type
type Sing Source # 
Instance details

Defined in Data.Singletons.Prelude.Semigroup.Internal

type Sing Source # 
Instance details

Defined in Data.Singletons.Prelude.Semigroup.Internal

type Sing = SOption :: Option a -> Type
type Sing Source # 
Instance details

Defined in Data.Singletons.Prelude.Instances

type Sing = SIdentity :: Identity a -> Type
type Sing Source # 
Instance details

Defined in Data.Singletons.Prelude.Monoid

type Sing = SFirst :: First a -> Type
type Sing Source # 
Instance details

Defined in Data.Singletons.Prelude.Monoid

type Sing = SLast :: Last a -> Type
type Sing Source # 
Instance details

Defined in Data.Singletons.Prelude.Semigroup.Internal

type Sing = SDual :: Dual a -> Type
type Sing Source # 
Instance details

Defined in Data.Singletons.Prelude.Semigroup.Internal

type Sing = SSum :: Sum a -> Type
type Sing Source # 
Instance details

Defined in Data.Singletons.Prelude.Semigroup.Internal

type Sing = SProduct :: Product a -> Type
type Sing Source # 
Instance details

Defined in Data.Singletons.Prelude.Ord

type Sing = SDown :: Down a -> Type
type Sing Source # 
Instance details

Defined in Data.Singletons.Prelude.Instances

type Sing = SNonEmpty :: NonEmpty a -> Type
type Sing Source # 
Instance details

Defined in Data.Singletons.Prelude.Instances

type Sing = SEither :: Either a b -> Type
type Sing Source # 
Instance details

Defined in Data.Singletons.Prelude.Instances

type Sing = STuple2 :: (a, b) -> Type
type Sing Source # 
Instance details

Defined in Data.Singletons.Prelude.Semigroup

type Sing = SArg :: Arg a b -> Type
type Sing Source # 
Instance details

Defined in Data.Singletons.Prelude.Proxy

type Sing = SProxy :: Proxy t -> Type
type Sing Source # 
Instance details

Defined in Data.Singletons.Internal

type Sing = SLambda :: (k1 ~> k2) -> Type
type Sing Source # 
Instance details

Defined in Data.Singletons.Internal

type Sing Source # 
Instance details

Defined in Data.Singletons.Sigma

type Sing = SSigma :: Sigma s t -> Type
type Sing Source # 
Instance details

Defined in Data.Singletons.Prelude.Instances

type Sing = STuple3 :: (a, b, c) -> Type
type Sing Source # 
Instance details

Defined in Data.Singletons.Prelude.Const

type Sing = SConst :: Const a b -> Type
type Sing Source # 
Instance details

Defined in Data.Singletons.Prelude.Instances

type Sing = STuple4 :: (a, b, c, d) -> Type
type Sing Source # 
Instance details

Defined in Data.Singletons.Prelude.Instances

type Sing = STuple5 :: (a, b, c, d, e) -> Type
type Sing Source # 
Instance details

Defined in Data.Singletons.Prelude.Instances

type Sing = STuple6 :: (a, b, c, d, e, f) -> Type
type Sing Source # 
Instance details

Defined in Data.Singletons.Prelude.Instances

type Sing = STuple7 :: (a, b, c, d, e, f, g) -> Type

data SErrorMessage em where Source #

Constructors

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 

showErrorMessage :: ErrorMessage -> String Source #

Convert an ErrorMessage into a human-readable String.

Defunctionalization symbols

data TextSym0 a6989586621681349583 Source #

Instances

Instances details
SingI (TextSym0 :: TyFun Symbol (ErrorMessage' Symbol) -> Type) Source # 
Instance details

Defined in Data.Singletons.TypeError

SuppressUnusedWarnings (TextSym0 :: TyFun s (ErrorMessage' s) -> Type) Source # 
Instance details

Defined in Data.Singletons.TypeError

type Apply (TextSym0 :: TyFun s (ErrorMessage' s) -> Type) (a6989586621681349583 :: s) Source # 
Instance details

Defined in Data.Singletons.TypeError

type Apply (TextSym0 :: TyFun s (ErrorMessage' s) -> Type) (a6989586621681349583 :: s) = TextSym1 a6989586621681349583

type TextSym1 (a6989586621681349583 :: s) = 'Text a6989586621681349583 :: ErrorMessage' (s :: Type) Source #

data ShowTypeSym0 a6989586621681349585 Source #

Instances

Instances details
SingI (ShowTypeSym0 :: TyFun t (ErrorMessage' Symbol) -> Type) Source # 
Instance details

Defined in Data.Singletons.TypeError

SuppressUnusedWarnings (ShowTypeSym0 :: TyFun t (ErrorMessage' s) -> Type) Source # 
Instance details

Defined in Data.Singletons.TypeError

type Apply (ShowTypeSym0 :: TyFun t (ErrorMessage' s) -> Type) (a6989586621681349585 :: t) Source # 
Instance details

Defined in Data.Singletons.TypeError

type Apply (ShowTypeSym0 :: TyFun t (ErrorMessage' s) -> Type) (a6989586621681349585 :: t) = ShowTypeSym1 a6989586621681349585 :: ErrorMessage' s

type ShowTypeSym1 (a6989586621681349585 :: t) = 'ShowType a6989586621681349585 :: ErrorMessage' (s :: Type) Source #

data (:<>:@#@$) a6989586621681349587 infixl 6 Source #

Instances

Instances details
SingI ((:<>:@#@$) :: TyFun (ErrorMessage' Symbol) (ErrorMessage' Symbol ~> ErrorMessage' Symbol) -> Type) Source # 
Instance details

Defined in Data.Singletons.TypeError

SuppressUnusedWarnings ((:<>:@#@$) :: TyFun (ErrorMessage' s) (ErrorMessage' s ~> ErrorMessage' s) -> Type) Source # 
Instance details

Defined in Data.Singletons.TypeError

type Apply ((:<>:@#@$) :: TyFun (ErrorMessage' s) (ErrorMessage' s ~> ErrorMessage' s) -> Type) (a6989586621681349587 :: ErrorMessage' s) Source # 
Instance details

Defined in Data.Singletons.TypeError

type Apply ((:<>:@#@$) :: TyFun (ErrorMessage' s) (ErrorMessage' s ~> ErrorMessage' s) -> Type) (a6989586621681349587 :: ErrorMessage' s) = (:<>:@#@$$) a6989586621681349587

data a6989586621681349587 :<>:@#@$$ a6989586621681349588 infixl 6 Source #

Instances

Instances details
SingI x => SingI ((:<>:@#@$$) x :: TyFun (ErrorMessage' Symbol) (ErrorMessage' Symbol) -> Type) Source # 
Instance details

Defined in Data.Singletons.TypeError

Methods

sing :: Sing ((:<>:@#@$$) x) Source #

SuppressUnusedWarnings ((:<>:@#@$$) a6989586621681349587 :: TyFun (ErrorMessage' s) (ErrorMessage' s) -> Type) Source # 
Instance details

Defined in Data.Singletons.TypeError

type Apply ((:<>:@#@$$) a6989586621681349587 :: TyFun (ErrorMessage' s) (ErrorMessage' s) -> Type) (a6989586621681349588 :: ErrorMessage' s) Source # 
Instance details

Defined in Data.Singletons.TypeError

type Apply ((:<>:@#@$$) a6989586621681349587 :: TyFun (ErrorMessage' s) (ErrorMessage' s) -> Type) (a6989586621681349588 :: ErrorMessage' s) = a6989586621681349587 :<>:@#@$$$ a6989586621681349588

type (:<>:@#@$$$) (a6989586621681349587 :: ErrorMessage' s) (a6989586621681349588 :: ErrorMessage' s) = '(:<>:) a6989586621681349587 a6989586621681349588 :: ErrorMessage' (s :: Type) infixl 6 Source #

data (:$$:@#@$) a6989586621681349590 infixl 5 Source #

Instances

Instances details
SingI ((:$$:@#@$) :: TyFun (ErrorMessage' Symbol) (ErrorMessage' Symbol ~> ErrorMessage' Symbol) -> Type) Source # 
Instance details

Defined in Data.Singletons.TypeError

SuppressUnusedWarnings ((:$$:@#@$) :: TyFun (ErrorMessage' s) (ErrorMessage' s ~> ErrorMessage' s) -> Type) Source # 
Instance details

Defined in Data.Singletons.TypeError

type Apply ((:$$:@#@$) :: TyFun (ErrorMessage' s) (ErrorMessage' s ~> ErrorMessage' s) -> Type) (a6989586621681349590 :: ErrorMessage' s) Source # 
Instance details

Defined in Data.Singletons.TypeError

type Apply ((:$$:@#@$) :: TyFun (ErrorMessage' s) (ErrorMessage' s ~> ErrorMessage' s) -> Type) (a6989586621681349590 :: ErrorMessage' s) = (:$$:@#@$$) a6989586621681349590

data a6989586621681349590 :$$:@#@$$ a6989586621681349591 infixl 5 Source #

Instances

Instances details
SingI x => SingI ((:$$:@#@$$) x :: TyFun (ErrorMessage' Symbol) (ErrorMessage' Symbol) -> Type) Source # 
Instance details

Defined in Data.Singletons.TypeError

Methods

sing :: Sing ((:$$:@#@$$) x) Source #

SuppressUnusedWarnings ((:$$:@#@$$) a6989586621681349590 :: TyFun (ErrorMessage' s) (ErrorMessage' s) -> Type) Source # 
Instance details

Defined in Data.Singletons.TypeError

type Apply ((:$$:@#@$$) a6989586621681349590 :: TyFun (ErrorMessage' s) (ErrorMessage' s) -> Type) (a6989586621681349591 :: ErrorMessage' s) Source # 
Instance details

Defined in Data.Singletons.TypeError

type Apply ((:$$:@#@$$) a6989586621681349590 :: TyFun (ErrorMessage' s) (ErrorMessage' s) -> Type) (a6989586621681349591 :: ErrorMessage' s) = a6989586621681349590 :$$:@#@$$$ a6989586621681349591

type (:$$:@#@$$$) (a6989586621681349590 :: ErrorMessage' s) (a6989586621681349591 :: ErrorMessage' s) = '(:$$:) a6989586621681349590 a6989586621681349591 :: ErrorMessage' (s :: Type) infixl 5 Source #

data TypeErrorSym0 a6989586621681349593 Source #

Instances

Instances details
SingI (TypeErrorSym0 :: TyFun PErrorMessage a -> Type) Source # 
Instance details

Defined in Data.Singletons.TypeError

SuppressUnusedWarnings (TypeErrorSym0 :: TyFun PErrorMessage a -> Type) Source # 
Instance details

Defined in Data.Singletons.TypeError

type Apply (TypeErrorSym0 :: TyFun PErrorMessage k2 -> Type) (a6989586621681349593 :: PErrorMessage) Source # 
Instance details

Defined in Data.Singletons.TypeError

type Apply (TypeErrorSym0 :: TyFun PErrorMessage k2 -> Type) (a6989586621681349593 :: PErrorMessage) = TypeErrorSym1 a6989586621681349593 :: k2

type TypeErrorSym1 (a6989586621681349593 :: PErrorMessage) = TypeError a6989586621681349593 :: a Source #