Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Synopsis
- data TypeInfo a
- typeConstructor :: TypeInfo a -> Constr
- fieldNames :: TypeInfo a -> [String]
- fieldTypes :: TypeInfo a -> [TypeRep]
- typeName :: TypeInfo a -> String
- typeInfo :: Data a => a -> TypeInfo a
- typeInfoFromContext :: forall a. Data a => TypeInfo a
Documentation
A data type holding meta-data about a type.
The Phantom type parameter a
ensures type safety for reflective functions
that use this type to create type instances (See module RecordtypeReflection).
typeConstructor :: TypeInfo a -> Constr Source #
fieldNames :: TypeInfo a -> [String] Source #
fieldTypes :: TypeInfo a -> [TypeRep] Source #
typeName :: TypeInfo a -> String Source #
This function returns the (unqualified) type name of a
from a `TypeInfo a` object.
typeInfo :: Data a => a -> TypeInfo a Source #
this function is a smart constructor for TypeInfo objects.
It takes a value of type a
and returns a `TypeInfo a` object.
If the type has no named fields, an error is thrown.
If the type has more than one constructor, an error is thrown.
typeInfoFromContext :: forall a. Data a => TypeInfo a Source #
This function creates a TypeInfo object from the context of a function call.
The Phantom Type parameter a
is used to convince the compiler that the `TypeInfo a` object really describes type a
.
See also https://stackoverflow.com/questions/75171829/how-to-obtain-a-data-data-constr-etc-from-a-type-representation