Module

Data.Generic

Package
purescript-generics
Repository
purescript/purescript-generics

#GenericSource

class Generic a  where

The Generic typeclass provides methods for sending data to/from spine representations, as well as querying about the signatures of spine representations.

For standard data structures, you can simply write derive instance genericFoo :: Generic Foo in the module they are declared, and the instance methods will be filled in for you.

Members

Instances

#GenericSpineSource

data GenericSpine

A GenericSpine is a universal representation of an arbitrary data structure (that does not contain function arrows).

Constructors

Instances

#GenericSignatureSource

data GenericSignature

A GenericSignature is a universal representation of the structure of an arbitrary data structure (that does not contain function arrows).

Constructors

Instances

#DataConstructorSource

type DataConstructor = { sigConstructor :: String, sigValues :: Array (Unit -> GenericSignature) }

Identifies a data constructor.

#isValidSpineSource

isValidSpine :: GenericSignature -> GenericSpine -> Boolean

Checks that the spine follows the structure defined by the signature

#gShowSource

gShow :: forall a. Generic a => a -> String

This function can be used as the default instance for Show for any instance of Generic

#gEqSource

gEq :: forall a. Generic a => a -> a -> Boolean

This function can be used as an implementation of the eq function of Eq for any type with a Generic instance.

Note: It is preferrable to use derive instance for Eq instances rather than relying on gEq, where possible.

#gCompareSource

gCompare :: forall a. Generic a => a -> a -> Ordering

This function can be used as an implementation of the compare function of Ord for any type with a Generic instance.

Note: It is preferrable to use derive instance for Ord instances rather than relying on gCompare, where possible.

Modules
Data.Generic