Module

Data.Generic

Package
purescript-genericsDEPRECATED
Repository
purescript/purescript-generics

#Generic Source

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

#GenericSpine Source

data GenericSpine

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

Constructors

Instances

#GenericSignature Source

data GenericSignature

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

Constructors

Instances

#DataConstructor Source

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

Identifies a data constructor.

#isValidSpine Source

isValidSpine :: GenericSignature -> GenericSpine -> Boolean

Checks that the spine follows the structure defined by the signature

#gShow Source

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

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

#gEq Source

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.

#gCompare Source

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