basic-sop-0.2.0.3: 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.

Minimal complete definition

Nothing

Methods

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

Returns a skeleton.

skeleton :: a Source #

Returns a skeleton.

Instances
Skeleton Bool Source # 
Instance details

Defined in Generics.SOP.Skeleton

Methods

skeleton :: Bool Source #

Skeleton Double Source # 
Instance details

Defined in Generics.SOP.Skeleton

Skeleton Int Source # 
Instance details

Defined in Generics.SOP.Skeleton

Methods

skeleton :: Int Source #

Skeleton Rational Source # 
Instance details

Defined in Generics.SOP.Skeleton

Skeleton Text Source # 
Instance details

Defined in Generics.SOP.Skeleton

Methods

skeleton :: Text Source #

Skeleton [a] Source # 
Instance details

Defined in Generics.SOP.Skeleton

Methods

skeleton :: [a] Source #

Skeleton (Maybe a) Source # 
Instance details

Defined in Generics.SOP.Skeleton

Methods

skeleton :: Maybe a Source #