Safe Haskell | None |
---|---|
Language | Haskell2010 |
Singleton types corresponding to type-level data structures.
The implementation is similar, but subtly different to that of the
singletons
package.
See the "True Sums of Products"
paper for details.
Synopsis
- data SList :: [k] -> Type where
- type SListI = All Top
- sList :: SListI xs => SList xs
- para_SList :: SListI xs => r '[] -> (forall y ys. SListI ys => r ys -> r (y ': ys)) -> r xs
- case_SList :: SListI xs => r '[] -> (forall y ys. SListI ys => r (y ': ys)) -> r xs
- data Shape :: [k] -> Type where
- shape :: forall (xs :: [k]). SListI xs => Shape xs
- lengthSList :: forall (xs :: [k]) proxy. SListI xs => proxy xs -> Int
Singletons
data SList :: [k] -> Type where Source #
Explicit singleton list.
A singleton list can be used to reveal the structure of
a type-level list argument that the function is quantified
over. For every type-level list xs
, there is one non-bottom
value of type
.SList
xs
Note that these singleton lists are polymorphic in the list elements; we do not require a singleton representation for them.
Since: sop-core-0.2
type SListI = All Top Source #
Implicit singleton list.
A singleton list can be used to reveal the structure of a type-level list argument that the function is quantified over.
Since 0.4.0.0, this is now defined in terms of All
.
A singleton list provides a witness for a type-level list
where the elements need not satisfy any additional
constraints.
Since: sop-core-0.4.0.0
sList :: SListI xs => SList xs Source #
Get hold of an explicit singleton (that one can then pattern match on) for a type-level list
para_SList :: SListI xs => r '[] -> (forall y ys. SListI ys => r ys -> r (y ': ys)) -> r xs Source #
Paramorphism for a type-level list.
Since: sop-core-0.4.0.0
case_SList :: SListI xs => r '[] -> (forall y ys. SListI ys => r (y ': ys)) -> r xs Source #
Case distinction on a type-level list.
Since: sop-core-0.4.0.0
Shape of type-level lists
data Shape :: [k] -> Type where Source #
Occassionally it is useful to have an explicit, term-level, representation of type-level lists (esp because of https://ghc.haskell.org/trac/ghc/ticket/9108 )
lengthSList :: forall (xs :: [k]) proxy. SListI xs => proxy xs -> Int Source #
The length of a type-level list.
Since: sop-core-0.2