lens-2.5: Lenses, Folds and Traversals

PortabilityRank2Types
Stabilityexperimental
MaintainerEdward Kmett <ekmett@gmail.com>
Safe HaskellTrustworthy

Data.Data.Lens

Contents

Description

Smart and naïve generic traversals given Data instances.

template, uniplate, and biplate each build up information about what types can be contained within another type to speed up Traversal.

Synopsis

Documentation

template :: forall a b. (Data a, Typeable b) => Simple Traversal a bSource

Find every occurence of a given type b recursively that doesn't require passing through something of type b using Data, while avoiding traversal of areas that cannot contain a value of type b.

This is uniplate with a more liberal signature.

tinplate :: (Data a, Typeable b) => Simple Traversal a bSource

Naïve Traversal using Data. This does not attempt to optimize the traversal.

This is primarily useful when the children are immediately obvious, and for benchmarking.

 tinplate :: (Data a, Typeable b) => Simple Traversal a b

uniplate :: Data a => Simple Traversal a aSource

Find descendants of type a non-transitively, while avoiding computation of areas that cannot contain values of type a using Data.

uniplate is a useful default definition for plate

biplate :: forall a b. (Data a, Typeable b) => Simple Traversal a bSource

biplate performs like template, except when a ~ b, it returns itself and nothing else.

Traversal of Data

gtraverse :: (Applicative f, Data a) => (forall d. Data d => d -> f d) -> a -> f aSource

A generic applicative transformation that maps over the immediate subterms.

gtraverse is to traverse what gmapM is to mapM

This really belongs in Data.Data.