Type-level error.
Modulefirst-class-families-0.8.2.0Haskell2010
Fcf.Utils
Miscellaneous families.
- 13 types
- 1 class
- Packagefirst-class-families-0.8.2.0
- Exports17
- LanguageHaskell2010
- LicenceMIT
- SourceUtils.hs
TypeError as a fcf.
Conjunction of a list of constraints.
Instances2Eval
type Eval (Constraints '[]) = ()Defined in first-class-families-0.8.2.0 · Fcf.Utilstype Eval (Constraints (a ': as)) = (a, Eval (Constraints as))Defined in first-class-families-0.8.2.0 · Fcf.Utils
A stuck type that can be used like a type-level undefined.
(Limited) equivalent of \case { .. } syntax. Supports matching of exact
values (-->) and final matches for any value (Any) or for passing value
to subcomputation (Else). Examples:
type BoolToNat = Case
[ 'True --> 0
, 'False --> 1
]
type NatToBool = Case
[ 0 --> 'False
, Any 'True
]
type ZeroOneOrSucc = Case
[ 0 --> 0
, 1 --> 1
, Else ((+) 1)
]
Match concrete type in Case.
Match on predicate being successful with type in Case.
Match any type in Case. Should be used as a final branch.
Note: this identifier conflicts with Any (from Fcf.Class.Foldable) Any (from Data.Monoid), and Any (from GHC.Exts).
We recommend importing this one qualified.
Pass type being matched in Case to subcomputation. Should be used as a final branch.
From Data.Type.Bool
1 declarationCompile-time asserts
2 declarationsReexports
2 declarationsA description of a custom type error.
Constructors
Text SymbolShow the text as is.
forall t. ShowType tPretty print the type.
ShowType :: k -> ErrorMessageErrorMessage :<>: ErrorMessageinfixl 6Put two pieces of error message next to each other.
ErrorMessage :$$: ErrorMessageinfixl 5Stack two pieces of error message on top of each other.
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.")