lens-3.5.1: Lenses, Folds and Traversals

MaintainerEdward Kmett <ekmett@gmail.com>
Safe HaskellTrustworthy




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.



template :: forall s a. (Data s, Typeable a) => Simple Traversal s aSource

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

This is uniplate with a more liberal signature.

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

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.

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 s a. (Data s, Typeable a) => Simple Traversal s aSource

biplate performs like template, except when s ~ a, 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.