Copyright | (c) 2011 Patrick Bahr |
---|---|

License | BSD3 |

Maintainer | Patrick Bahr <paba@diku.dk> |

Stability | experimental |

Portability | non-portable (GHC Extensions) |

Safe Haskell | None |

Language | Haskell98 |

This module defines type generic functions and recursive schemes along the lines of the Uniplate library. All definitions are generalised versions of those in Data.Comp.Generic.

## Synopsis

- subterms :: forall f. HFoldable f => Term f :=> [E (Term f)]
- subterms' :: forall f g. (HFoldable f, g :<: f) => Term f :=> [E (g (Term f))]
- transform :: forall f. HFunctor f => (Term f :-> Term f) -> Term f :-> Term f
- transformM :: forall f m. (HTraversable f, Monad m) => NatM m (Term f) (Term f) -> NatM m (Term f) (Term f)
- query :: HFoldable f => (Term f :=> r) -> (r -> r -> r) -> Term f :=> r
- subs :: HFoldable f => Term f :=> [E (Term f)]
- subs' :: (HFoldable f, g :<: f) => Term f :=> [E (g (Term f))]
- size :: HFoldable f => Cxt h f a :=> Int
- depth :: HFoldable f => Cxt h f a :=> Int

# Documentation

subterms :: forall f. HFoldable f => Term f :=> [E (Term f)] Source #

This function returns a list of all subterms of the given
term. This function is similar to Uniplate's `universe`

function.

subterms' :: forall f g. (HFoldable f, g :<: f) => Term f :=> [E (g (Term f))] Source #

This function returns a list of all subterms of the given term that are constructed from a particular functor.

transform :: forall f. HFunctor f => (Term f :-> Term f) -> Term f :-> Term f Source #

This function transforms every subterm according to the given
function in a bottom-up manner. This function is similar to
Uniplate's `transform`

function.

transformM :: forall f m. (HTraversable f, Monad m) => NatM m (Term f) (Term f) -> NatM m (Term f) (Term f) Source #

Monadic version of `transform`

.