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

Safe HaskellNone
LanguageHaskell2010

Generics.SOP.Skeleton

Description

Generic computation of a skeleton.

Synopsis

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.

Methods

skeleton :: (Generic a, HasDatatypeInfo a, Code a ~ '[xs], All Skeleton xs) => a Source #

Returns a skeleton.

skeleton :: a Source #

Returns a skeleton.