cubix-compdata-1.0.1: Compositional Data Types for Cubix
Copyright (c) 2011 Patrick Bahr BSD3 Patrick Bahr experimental non-portable (GHC Extensions) None Haskell98

Data.Comp.Multi.Generic

Description

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

# Documentation

subterms :: forall f. HFoldable f => HFix f :=> [E (HFix 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) => HFix f :=> [E (g (HFix 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 => (HFix f :-> HFix f) -> HFix f :-> HFix f Source #

transform :: (forall i. Term fs i -> Term fs i) -> Term f l -> Term f l


If f :: Term fs i -> Term fs i rewrites a single node, then transform f t is the result of running f on all nodes within t in a bottom-up fashion.

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

Monadic version of transform.

query :: HFoldable f => (HFix f :=> r) -> (r -> r -> r) -> HFix f :=> r Source #

query :: (forall i. Term fs i -> r) -> (r -> r -> r) -> Term fs l -> r


Example usage: let getConsts :: (IntConst :-fs) = Term fs l -> [Int] be a function where getConsts (iIntConst n) = [n], and getConsts t = [] for everything that is not an IntConst. Then

query getConsts (++) term


returns a list of all integer constants in term.

subs :: HFoldable f => HFix f :=> [E (HFix f)] Source #

subs' :: (HFoldable f, g :<: f) => HFix f :=> [E (g (HFix f))] Source #

size :: HFoldable f => Cxt h f a :=> Int Source #

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

depth :: HFoldable f => Cxt h f a :=> Int Source #

This function computes the generic depth of the given term.