Singleton types
code:singleton.hs
data Question a = Q String (QType a)
deriving instance Show (Question a)
data QType :: * -> * where
QYesNo :: QType Bool
QQuant :: QType Int
deriving instance Show (QType a)
The types Qtype a are singleton types
For each a, there's at most one non-bottom value of type Qtype a
Singleton types provide a term-level representative for types.
Singleton types are quite a useful concept in type-level programming that we'll encounter frequently.
Useful links