Portability | non-portable (local universal quantification) |
---|---|
Stability | experimental |
Maintainer | generics@haskell.org |
Safe Haskell | Safe-Inferred |
"Scrap your boilerplate" --- Generic programming in Haskell See http://www.cs.uu.nl/wiki/GenericProgramming/SYB. The present module provides frequently used generic traversal schemes.
- everywhere :: (forall a. Data a => a -> a) -> forall a. Data a => a -> a
- everywhere' :: (forall a. Data a => a -> a) -> forall a. Data a => a -> a
- everywhereBut :: GenericQ Bool -> GenericT -> GenericT
- everywhereM :: Monad m => GenericM m -> GenericM m
- somewhere :: MonadPlus m => GenericM m -> GenericM m
- everything :: (r -> r -> r) -> GenericQ r -> GenericQ r
- everythingBut :: (r -> r -> r) -> GenericQ (r, Bool) -> GenericQ r
- everythingWithContext :: s -> (r -> r -> r) -> GenericQ (s -> (r, s)) -> GenericQ r
- listify :: Typeable r => (r -> Bool) -> GenericQ [r]
- something :: GenericQ (Maybe u) -> GenericQ (Maybe u)
- synthesize :: s -> (t -> s -> s) -> GenericQ (s -> t) -> GenericQ t
- gsize :: Data a => a -> Int
- glength :: GenericQ Int
- gdepth :: GenericQ Int
- gcount :: GenericQ Bool -> GenericQ Int
- gnodecount :: GenericQ Int
- gtypecount :: Typeable a => a -> GenericQ Int
- gfindtype :: (Data x, Typeable y) => x -> Maybe y
Documentation
everywhere :: (forall a. Data a => a -> a) -> forall a. Data a => a -> aSource
Apply a transformation everywhere in bottom-up manner
everywhere' :: (forall a. Data a => a -> a) -> forall a. Data a => a -> aSource
Apply a transformation everywhere in top-down manner
everywhereBut :: GenericQ Bool -> GenericT -> GenericTSource
Variation on everywhere with an extra stop condition
everywhereM :: Monad m => GenericM m -> GenericM mSource
Monadic variation on everywhere
somewhere :: MonadPlus m => GenericM m -> GenericM mSource
Apply a monadic transformation at least somewhere
everything :: (r -> r -> r) -> GenericQ r -> GenericQ rSource
Summarise all nodes in top-down, left-to-right order
everythingBut :: (r -> r -> r) -> GenericQ (r, Bool) -> GenericQ rSource
Variation of everything with an added stop condition
everythingWithContext :: s -> (r -> r -> r) -> GenericQ (s -> (r, s)) -> GenericQ rSource
Summarise all nodes in top-down, left-to-right order, carrying some state down the tree during the computation, but not left-to-right to siblings.
listify :: Typeable r => (r -> Bool) -> GenericQ [r]Source
Get a list of all entities that meet a predicate
something :: GenericQ (Maybe u) -> GenericQ (Maybe u)Source
Look up a subterm by means of a maybe-typed filter
synthesize :: s -> (t -> s -> s) -> GenericQ (s -> t) -> GenericQ tSource
Bottom-up synthesis of a data structure; 1st argument z is the initial element for the synthesis; 2nd argument o is for reduction of results from subterms; 3rd argument f updates the synthesised data according to the given term
gcount :: GenericQ Bool -> GenericQ IntSource
Determine the number of all suitable nodes in a given term
gnodecount :: GenericQ IntSource
Determine the number of all nodes in a given term
gtypecount :: Typeable a => a -> GenericQ IntSource
Determine the number of nodes of a given type in a given term