|
| Data.Generics.Basics | | Portability | non-portable | | Stability | experimental | | Maintainer | libraries@haskell.org |
|
|
|
|
|
| Description |
| "Scrap your boilerplate" --- Generic programming in Haskell
See http://www.cs.vu.nl/boilerplate/. The present module provides
the Data class with its primitives for generic programming.
|
|
| Synopsis |
|
|
|
| Documentation |
|
| module Data.Typeable |
|
| The Data class for processing constructor applications |
|
| class Typeable a => Data a where |
| | Methods | | gfoldl :: (forall a b . Data a => c (a -> b) -> a -> c b) -> (forall g . g -> c g) -> a -> c a | | Left-associative fold operation for constructor applications | | | toConstr :: a -> Constr | | Obtaining the constructor from a given datum.
For proper terms, this is meant to be the top-level constructor.
Primitive datatypes are here viewed as potentially infinite sets of
values (i.e., constructors).
| | | fromConstr :: Constr -> a | | Building a term from a constructor | | | dataTypeOf :: a -> DataType | | Provide access to list of all constructors |
| | | Instances | |
|
|
| Constructor representations |
|
| data Constr |
| Representation of constructors | | Instances | |
|
|
| type ConIndex = Int |
| Unique index for datatype constructors.
Textual order is respected. Starts at 1.
|
|
| data Fixity |
| Fixity of constructors | | Constructors | | | Instances | |
|
|
| data DataType |
| A package of constructor representations;
could be a list, an array, a balanced tree, or others.
| | Instances | |
|
|
| Constructing constructor representations |
|
| mkConstr :: ConIndex -> String -> Fixity -> Constr |
| Make a representation for a datatype constructor |
|
| mkDataType :: [Constr] -> DataType |
| Make a package of constructor representations |
|
| Observing constructor representations |
|
| conString :: Constr -> String |
| Turn a constructor into a string |
|
| conFixity :: Constr -> Fixity |
| Determine fixity of a constructor;
undefined for primitive types. |
|
| conIndex :: Constr -> ConIndex |
| Determine index of a constructor.
Undefined for primitive types. |
|
| stringCon :: DataType -> String -> Maybe Constr |
| Lookup a constructor via a string |
|
| indexCon :: DataType -> ConIndex -> Constr |
| Lookup a constructor by its index; |
|
| maxConIndex :: DataType -> ConIndex |
| Return maximum index;
0 for primitive types |
|
| dataTypeCons :: DataType -> [Constr] |
| Return all constructors in increasing order of indicies;
empty list for primitive types |
|
| Generic maps defined in terms of gfoldl |
|
| gmapT :: Data a => (forall b . Data b => b -> b) -> a -> a |
| A generic transformation that maps over the immediate subterms |
|
| gmapQ :: Data a => (forall a . Data a => a -> u) -> a -> [u] |
| A generic query that processes the immediate subterms and returns a list |
|
| gmapQl :: Data a => (r -> r' -> r) -> r -> (forall a . Data a => a -> r') -> a -> r |
| A generic query with a left-associative binary operator |
|
| gmapQr :: Data a => (r' -> r -> r) -> r -> (forall a . Data a => a -> r') -> a -> r |
| A generic query with a right-associative binary operator |
|
| gmapM :: (Data a, Monad m) => (forall a . Data a => a -> m a) -> a -> m a |
| A generic monadic transformation that maps over the immediate subterms |
|
| gmapMp :: (Data a, MonadPlus m) => (forall a . Data a => a -> m a) -> a -> m a |
| Transformation of at least one immediate subterm does not fail |
|
| gmapMo :: (Data a, MonadPlus m) => (forall a . Data a => a -> m a) -> a -> m a |
| Transformation of one immediate subterm with success |
|
| Produced by Haddock version 0.6 |