Safe Haskell | None |
---|---|
Language | Haskell2010 |
Generic computation of a skeleton.
Documentation
A skeleton for a record type has a defined "spine" but is undefined everywhere else. For instance, a skeleton for pairs would be
(undefined, undefined)
class Skeleton a where Source #
Generic computation of a skeleton.
A skeleton for a record type has a defined "spine" but is undefined everywhere else. For instance, a skeleton for pairs would be
(undefined, undefined)
We introduce a type class for this purpose because the skeleton for nested records would look like
(undefined, (undefined, undefined))
The default instance of skeleton
applies to record types; for everything
else, use undefined (or error):
instance Skeleton SomeRecordType -- no where clause
or
instance Skeleton SomeNonRecordType where skeleton = undefined
This is an example of how SOP-style generic functions can
be used with DefaultSignatures
.
Furthermore, metadata is used in order to produce better error messages. For the undefined components of a record, an error is triggered that mentions the name of the field.
Nothing
skeleton :: (Generic a, HasDatatypeInfo a, Code a ~ '[xs], All Skeleton xs) => a Source #
Returns a skeleton.
Returns a skeleton.
Instances
Skeleton Bool Source # | |
Defined in Generics.SOP.Skeleton | |
Skeleton Double Source # | |
Defined in Generics.SOP.Skeleton | |
Skeleton Int Source # | |
Defined in Generics.SOP.Skeleton | |
Skeleton Rational Source # | |
Defined in Generics.SOP.Skeleton | |
Skeleton Text Source # | |
Defined in Generics.SOP.Skeleton | |
Skeleton [a] Source # | |
Defined in Generics.SOP.Skeleton | |
Skeleton (Maybe a) Source # | |
Defined in Generics.SOP.Skeleton |