generics-sop-0.2.0.0: Generic Programming using True Sums of Products

Safe HaskellSafe
LanguageHaskell2010

Generics.SOP.Sing

Contents

Description

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

Singletons

data SList :: [k] -> * 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.

Constructors

SNil :: SList `[]` 
SCons :: SListI xs => SList (x : xs) 

Instances

Eq (SList k xs) Source 
Ord (SList k xs) Source 
Show (SList k xs) Source 

class SListI xs where 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.

The class SListI should have instances that match the constructors of SList.

Methods

sList :: SList xs Source

Get hold of the explicit singleton (that one can then pattern match on).

Instances

SListI k ([] k) Source 
SListI k xs => SListI k ((:) k x xs) Source 

type Sing = SList Source

Deprecated: Use SList instead.

Explicit singleton type.

Just provided for limited backward compatibility.

class SListI xs => SingI xs where Source

Deprecated: Use SListI instead.

General class for implicit singletons.

Just provided for limited backward compatibility.

Methods

sing :: Sing xs Source

Deprecated: Use sList instead.

Shape of type-level lists

data Shape :: [k] -> * 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)

Constructors

ShapeNil :: Shape `[]` 
ShapeCons :: SListI xs => Shape xs -> Shape (x : xs) 

Instances

Eq (Shape k xs) Source 
Ord (Shape k xs) Source 
Show (Shape k xs) Source 

shape :: forall xs. SListI xs => Shape xs Source

The shape of a type-level list.

lengthSList :: forall xs proxy. SListI xs => proxy xs -> Int Source

The length of a type-level list.

lengthSing :: SListI xs => proxy xs -> Int Source

Deprecated: Use lengthSList instead.

Old name for lengthSList.