Safe Haskell | None |
---|---|
Language | Haskell2010 |
Constraints for indexed datatypes.
This module contains code that helps to specify that all elements of an indexed structure must satisfy a particular constraint.
- type family All c xs :: Constraint
- type family All2 c xs :: Constraint
- type family Map f xs :: [l]
- type family AllMap h c xs :: Constraint
- data AllDict c xs where
- data Constraint :: BOX
Documentation
type family All c xs :: Constraint Source
Require a constraint for every element of a list.
If you have a datatype that is indexed over a type-level
list, then you can use All
to indicate that all elements
of that type-level list must satisfy a given constraint.
Example: The constraint
All Eq '[ Int, Bool, Char ]
is equivalent to the constraint
(Eq Int, Eq Bool, Eq Char)
Example: A type signature such as
f :: All Eq xs => NP I xs -> ...
means that f
can assume that all elements of the n-ary
product satisfy Eq
.
type family All2 c xs :: Constraint Source
Require a constraint for every element of a list of lists.
If you have a datatype that is indexed over a type-level
list of lists, then you can use All2
to indicate that all
elements of the innert lists must satisfy a given constraint.
Example: The constraint
All2 Eq '[ '[ Int ], '[ Bool, Char ] ]
is equivalent to the constraint
(Eq Int, Eq Bool, Eq Char)
Example: A type signature such as
f :: All2 Eq xss => SOP I xs -> ...
means that f
can assume that all elements of the sum
of product satisfy Eq
.
type family AllMap h c xs :: Constraint Source
data AllDict c xs where Source
Dictionary for a constraint for all elements of a type-level list.
A value of type
captures the constraint AllDict
c xs
.All
c xs
Typeable ((k -> Constraint) -> [k] -> *) (AllDict k) |
data Constraint :: BOX
Typeable ((* -> *) -> Constraint) Alternative | |
Typeable ((* -> *) -> Constraint) Applicative | |
Typeable (* -> Constraint) Monoid | |
Typeable (* -> Constraint) HasDatatypeInfo | |
Typeable (* -> Constraint) Generic | |
Typeable ((k -> Constraint) -> [k] -> *) (AllDict k) | |
Typeable (((k -> *) -> k -> *) -> Constraint) (HPure k k) | |
Typeable (((k -> *) -> k -> *) -> Constraint) (HAp k k) | |
Typeable (((k -> *) -> k -> *) -> Constraint) (HCollapse k k) | |
Typeable (((k -> *) -> k -> *) -> Constraint) (HSequence k k) |