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
toSpine :: a -> GenericSpine
toSignature :: Proxy a -> GenericSignature
fromSpine :: GenericSpine -> Maybe a
Instances
Generic Number
Generic Int
Generic String
Generic Char
Generic Boolean
(Generic a) => Generic (Array a)
Generic Unit
Generic Void
(Generic a, Generic b) => Generic (Tuple a b)
(Generic a) => Generic (List a)
(Generic a) => Generic (NonEmptyList a)
(Generic a) => Generic (Maybe a)
(Generic a, Generic b) => Generic (Either a b)
(Generic a) => Generic (Identity a)
Generic Ordering
(Generic (f a), Generic a) => Generic (NonEmpty f a)
#GenericSpine Source
data GenericSpine
A GenericSpine is a universal representation of an arbitrary data structure (that does not contain function arrows).
Constructors
SProd String (Array (Unit -> GenericSpine))
SRecord (Array { recLabel :: String, recValue :: Unit -> GenericSpine })
SNumber Number
SBoolean Boolean
SInt Int
SString String
SChar Char
SArray (Array (Unit -> GenericSpine))
SUnit
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
SigProd String (Array DataConstructor)
SigRecord (Array { recLabel :: String, recValue :: Unit -> GenericSignature })
SigNumber
SigBoolean
SigInt
SigString
SigChar
SigArray (Unit -> GenericSignature)
SigUnit
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
- Modules
- Data.
Generic