Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Common type functions
- data Nat :: *
- data Symbol :: *
- natValue :: forall n a. (KnownNat n, Num a) => a
- natValue' :: forall n. KnownNat n => Word
- symbolValue :: forall s. KnownSymbol s => String
- class KnownNat n
- class KnownSymbol n
- type family CmpNat (a :: Nat) (b :: Nat) :: Ordering where ...
- type family CmpSymbol (a :: Symbol) (b :: Symbol) :: Ordering where ...
- type family (a :: Nat) <=? (b :: Nat) :: Bool where ...
- type (<=) x y = (~) Bool ((<=?) x y) True
- type family (a :: Nat) + (b :: Nat) :: Nat where ...
- type family (a :: Nat) - (b :: Nat) :: Nat where ...
- type family (a :: Nat) * (b :: Nat) :: Nat where ...
- type family (a :: Nat) ^ (b :: Nat) :: Nat where ...
- type family If c t e where ...
- type family IfNat c (t :: Nat) (e :: Nat) where ...
- type family Modulo (a :: Nat) (b :: Nat) where ...
- type family Same a b :: Nat where ...
- data Proxy k t :: forall k. k -> * = Proxy
- type family TypeError b (a :: ErrorMessage) :: b where ...
- data ErrorMessage :: * where
Documentation
(Kind) This is the kind of type-level symbols. Declared here because class IP needs it
symbolValue :: forall s. KnownSymbol s => String Source #
Get a Symbol value
This class gives the integer associated with a type-level natural. There are instances of the class for every concrete literal: 0, 1, 2, etc.
Since: 4.7.0.0
natSing
class KnownSymbol n #
This class gives the string associated with a type-level symbol. There are instances of the class for every concrete literal: "hello", etc.
Since: 4.7.0.0
symbolSing
type family CmpNat (a :: Nat) (b :: Nat) :: Ordering where ... #
Comparison of type-level naturals, as a function.
Since: 4.7.0.0
type family CmpSymbol (a :: Symbol) (b :: Symbol) :: Ordering where ... #
Comparison of type-level symbols, as a function.
Since: 4.7.0.0
type family (a :: Nat) <=? (b :: Nat) :: Bool where ... infix 4 #
Comparison of type-level naturals, as a function.
NOTE: The functionality for this function should be subsumed
by CmpNat
, so this might go away in the future.
Please let us know, if you encounter discrepancies between the two.
type (<=) x y = (~) Bool ((<=?) x y) True infix 4 #
Comparison of type-level naturals, as a constraint.
type family (a :: Nat) - (b :: Nat) :: Nat where ... infixl 6 #
Subtraction of type-level naturals.
Since: 4.7.0.0
type family (a :: Nat) * (b :: Nat) :: Nat where ... infixl 7 #
Multiplication of type-level naturals.
type family (a :: Nat) ^ (b :: Nat) :: Nat where ... infixr 8 #
Exponentiation of type-level naturals.
data Proxy k t :: forall k. k -> * #
A concrete, poly-kinded proxy type
Monad (Proxy *) | |
Functor (Proxy *) | |
Applicative (Proxy *) | |
Foldable (Proxy *) | |
Traversable (Proxy *) | |
Generic1 (Proxy *) | |
Eq1 (Proxy *) | Since: 4.9.0.0 |
Ord1 (Proxy *) | Since: 4.9.0.0 |
Read1 (Proxy *) | Since: 4.9.0.0 |
Show1 (Proxy *) | Since: 4.9.0.0 |
Alternative (Proxy *) | |
MonadPlus (Proxy *) | |
Hashable1 (Proxy *) | |
Bounded (Proxy k s) | |
Enum (Proxy k s) | |
Eq (Proxy k s) | |
Ord (Proxy k s) | |
Read (Proxy k s) | |
Show (Proxy k s) | |
Ix (Proxy k s) | |
Generic (Proxy k t) | |
Semigroup (Proxy k s) | |
Monoid (Proxy k s) | |
Hashable (Proxy * a) | |
type Rep1 (Proxy *) | |
type Rep (Proxy k t) | |
type family TypeError b (a :: ErrorMessage) :: b where ... #
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-existant 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.")
Since: 4.9.0.0
data ErrorMessage :: * where #
A description of a custom type error.
Text :: ErrorMessage | Show the text as is. |
ShowType :: ErrorMessage | Pretty print the type.
|
(:<>:) :: ErrorMessage infixl 6 | Put two pieces of error message next to each other. |
(:$$:) :: ErrorMessage infixl 5 | Stack two pieces of error message on top of each other. |