|
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 |
|
|
|
|
Module Data.Typeable re-exported for convenience
|
|
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
| | gunfold :: (forall b r . Data b => c (b -> r) -> c r) -> (forall r . r -> c r) -> Constr -> c a | Unfolding 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).
| | dataTypeOf :: a -> DataType | Provide access to list of all constructors
| | dataCast1 :: Typeable1 t => (forall a . Data a => c (t a)) -> Maybe (c a) | Mediate types and unary type constructors
| | dataCast2 :: Typeable2 t => (forall a b . (Data a, Data b) => c (t a b)) -> Maybe (c a) | Mediate types and binary type constructors
| | gmapT :: (forall b . Data b => b -> b) -> a -> a | A generic transformation that maps over the immediate subterms
| | gmapQl :: (r -> r' -> r) -> r -> (forall a . Data a => a -> r') -> a -> r | A generic query with a left-associative binary operator
| | gmapQr :: (r' -> r -> r) -> r -> (forall a . Data a => a -> r') -> a -> r | A generic query with a right-associative binary operator
| | gmapQ :: (forall a . Data a => a -> u) -> a -> [u] | A generic query that processes the immediate subterms and returns a list
| | gmapQi :: Int -> (forall a . Data a => a -> u) -> a -> u | A generic query that processes one child by index (zero-based)
| | gmapM :: Monad m => (forall a . Data a => a -> m a) -> a -> m a | A generic monadic transformation that maps over the immediate subterms
| | gmapMp :: MonadPlus m => (forall a . Data a => a -> m a) -> a -> m a | Transformation of at least one immediate subterm does not fail
| | gmapMo :: MonadPlus m => (forall a . Data a => a -> m a) -> a -> m a | Transformation of one immediate subterm with success
|
| | Instances | Data Bool | Data Char | Data DataType | Data Double | Data Float | Data Handle | Data Int | Data Int16 | Data Int32 | Data Int64 | Data Int8 | Data IntSet | Data Integer | Data Ordering | Data ThreadId | Data TyCon | Data TypeRep | Data Word | Data Word16 | Data Word32 | Data Word64 | Data Word8 | Data () | (Data a, Data b) => Data (a, b) | (Data a, Data b, Data c) => Data (a, b, c) | (Data a, Data b, Data c, Data d) => Data (a, b, c, d) | (Data a, Data b, Data c, Data d, Data e) => Data (a, b, c, d, e) | (Data a, Data b, Data c, Data d, Data e, Data f) => Data (a, b, c, d, e, f) | (Data a, Data b, Data c, Data d, Data e, Data f, Data g) => Data (a, b, c, d, e, f, g) | (Data a, Data b) => Data (a -> b) | Typeable a => Data (ForeignPtr a) | Typeable a => Data (IO a) | Typeable a => Data (IORef a) | Data a => Data (IntMap a) | Typeable a => Data (MVar a) | Data a => Data (Maybe a) | Typeable a => Data (Ptr a) | (Data a, Integral a) => Data (Ratio a) | Typeable a => Data (STM a) | (Data a, Ord a) => Data (Set a) | Typeable a => Data (StablePtr a) | Typeable a => Data (TVar a) | Data a => Data [a] | (Typeable a, Data b, Ix a) => Data (Array a b) | (Data a, Data b) => Data (Either a b) | (Data a, Data b, Ord a) => Data (FiniteMap a b) | (Data k, Data a, Ord k) => Data (Map k a) | (Typeable s, Typeable a) => Data (ST s a) |
|
|
|
Datatype representations
|
|
data DataType |
Representation of datatypes.
| A package of constructor representations with names of type and module.
| The list of constructors could be an array, a balanced tree, or others.
| Instances | |
|
|
data Constr |
Representation of constructors
| Instances | |
|
|
data DataRep |
Public representation of datatypes
| Constructors | AlgRep [Constr] | | IntRep | | FloatRep | | StringRep | | NoRep | |
| Instances | |
|
|
data ConstrRep |
Public representation of constructors
| Constructors | | Instances | |
|
|
type ConIndex = Int |
Unique index for datatype constructors.
| Textual order is respected. Starts at 1.
|
|
data Fixity |
Fixity of constructors
| Constructors | | Instances | |
|
|
Observers for datatype representations
|
|
dataTypeName :: DataType -> String |
Gets the type constructor including the module
|
|
dataTypeRep :: DataType -> DataRep |
Gets the public presentation of datatypes
|
|
constrType :: Constr -> DataType |
Gets the datatype of a constructor
|
|
constrRep :: Constr -> ConstrRep |
Gets the public presentation of constructors
|
|
repConstr :: DataType -> ConstrRep -> Constr |
Look up a constructor by its representation
|
|
Representations of algebraic data types
|
|
mkDataType :: String -> [Constr] -> DataType |
Constructs an algebraic datatype
|
|
mkConstr :: DataType -> String -> [String] -> Fixity -> Constr |
Constructs a constructor
|
|
dataTypeConstrs :: DataType -> [Constr] |
Gets the constructors
|
|
constrFields :: Constr -> [String] |
Gets the field labels of a constructor
|
|
constrFixity :: Constr -> Fixity |
Gets the fixity of a constructor
|
|
From strings to constr's and vice versa: all data types
|
|
showConstr :: Constr -> String |
Gets the string for a constructor
|
|
readConstr :: DataType -> String -> Maybe Constr |
Lookup a constructor via a string
|
|
Convenience funtions: algebraic data types
|
|
isAlgType :: DataType -> Bool |
Test for an algebraic type
|
|
indexConstr :: DataType -> ConIndex -> Constr |
Gets the constructor for an index
|
|
constrIndex :: Constr -> ConIndex |
Gets the index of a constructor
|
|
maxConstrIndex :: DataType -> ConIndex |
Gets the maximum constructor index
|
|
Representation of primitive types
|
|
mkIntType :: String -> DataType |
Constructs the Int type
|
|
mkFloatType :: String -> DataType |
Constructs the Float type
|
|
mkStringType :: String -> DataType |
Constructs the String type
|
|
mkIntConstr :: DataType -> Integer -> Constr |
|
mkFloatConstr :: DataType -> Double -> Constr |
|
mkStringConstr :: DataType -> String -> Constr |
|
Non-representations for non-presentable types
|
|
mkNorepType :: String -> DataType |
Constructs a non-representation
|
|
isNorepType :: DataType -> Bool |
Test for a non-representable type
|
|
Convenience functions: take type constructors apart
|
|
tyconUQname :: String -> String |
Gets the unqualified type constructor
Drop *.*.*... before name
|
|
tyconModule :: String -> String |
Gets the module of a type constructor
Take *.*.*... before name
|
|
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
|
|
gmapQi :: Data a => Int -> (forall a . Data a => a -> u) -> a -> u |
A generic query that processes one child by index (zero-based)
|
|
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
|
|
Generic operation(s) defined in terms of gunfold
|
|
fromConstr :: Data a => Constr -> a |
Build a term skeleton
|
|
fromConstrB :: Data a => (forall a . Data a => a) -> Constr -> a |
Build a term and use a generic function for subterms
|
|
fromConstrM :: (Monad m, Data a) => (forall a . Data a => m a) -> Constr -> m a |
Monadic variation on "fromConstrB"
|
|
Produced by Haddock version 0.7 |