compdata-0.5.1: Compositional Data Types

Portabilitynon-portable (GHC Extensions)
Stabilityexperimental
MaintainerPatrick Bahr <paba@diku.dk>

Data.Comp.Generic

Description

This module defines type generic functions and recursive schemes along the lines of the Uniplate library.

Synopsis

Documentation

subterms :: forall f. Foldable f => Term f -> [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. (Foldable f, g :<: f) => Term f -> [g (Term f)]Source

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

transform :: Functor f => (Term f -> Term f) -> Term f -> Term fSource

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

transform' :: Functor f => (Term f -> Maybe (Term f)) -> Term f -> Term fSource

transformM :: (Traversable f, Monad m) => (Term f -> m (Term f)) -> Term f -> m (Term f)Source

Monadic version of transform.

query :: Foldable f => (Term f -> r) -> (r -> r -> r) -> Term f -> rSource

size :: Foldable f => Cxt h f a -> IntSource

This function computes the generic size of the given term, i.e. the its number of subterm occurrences.

height :: Foldable f => Cxt h f a -> IntSource

This function computes the generic height of the given term.