Safe Haskell | None |
---|---|
Language | Haskell2010 |
Generic computation of a skeleton.
- class Skeleton a where
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.