|Copyright||(C) 2013 Richard Eisenberg|
|License||BSD-style (see LICENSE)|
|Maintainer||Richard Eisenberg (email@example.com)|
This file implements
singletonStar, which generates a datatype
Rep and associated
singleton from a list of types. The promoted version of
Rep is kind
* and the
Haskell types themselves. This is still very experimental, so expect unusual
Produce a representation and singleton for the collection of types given.
Rep is created, with one constructor per type in the declared
universe. When this type is promoted by the singletons library, the
constructors become full types in
*, not just promoted data constructors.
$(singletonStar [''Nat, ''Bool, ''Maybe])
generates the following:
data Rep = Nat | Bool | Maybe Rep deriving (Eq, Show, Read)
and its singleton. However, because
Rep is promoted to
*, the singleton
is perhaps slightly unexpected:
data instance Sing (a :: *) where SNat :: Sing Nat SBool :: Sing Bool SMaybe :: SingRep a => Sing a -> Sing (Maybe a)
The unexpected part is that
Maybe above are the real
Maybe, not just promoted data constructors.
Please note that this function is very experimental. Use at your own risk.