basic-sop- Basic examples and functions for generics-sop

Safe HaskellNone



Generic computation of a skeleton.




class Skeleton a whereSource

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


 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.


skeleton :: aSource

Returns a skeleton.