uniplate-1.6.12: Help writing simple, concise and fast generic operations.

Safe Haskell | None
Language | Haskell98

Data.Generics.UniplateOn

Contents

- Types
- Operations
  - Queries
  - Transformations
  - Other
- Helper for writing instances

Description

DEPRECATED: Use Data.Generics.Uniplate.Operations instead.

This module retained Haskell 98 compatability, but users who are happy with multi-parameter type classes should look towards Data.Generics.Biplate.

The only function missing from Data.Generics.Uniplate is `fold`, as it can be constructed from `children` and has little meaning in a multi-typed setting.

All operations, apart from `childrenOn` should perform identically to their non `On` counterparts.

Synopsis

- module Data.Generics.Uniplate
- type BiplateType from to = from -> ([to], [to] -> from)
- universeOn :: Uniplate to => BiplateType from to -> from -> [to]
- childrenOn :: Uniplate to => BiplateType from to -> from -> [to]
- transformOn :: Uniplate to => BiplateType from to -> (to -> to) -> from -> from
- transformOnM :: (Monad m, Uniplate to) => BiplateType from to -> (to -> m to) -> from -> m from
- rewriteOn :: Uniplate to => BiplateType from to -> (to -> Maybe to) -> from -> from
- rewriteOnM :: (Monad m, Uniplate to) => BiplateType from to -> (to -> m (Maybe to)) -> from -> m from
- descendOn :: Uniplate to => BiplateType from to -> (to -> to) -> from -> from
- descendOnM :: (Monad m, Uniplate to) => BiplateType from to -> (to -> m to) -> from -> m from
- holesOn :: Uniplate to => BiplateType from to -> from -> [(to, to -> from)]
- contextsOn :: Uniplate to => BiplateType from to -> from -> [(to, to -> from)]
- uniplateOnList :: BiplateType a b -> BiplateType [a] b

# Documentation

module Data.Generics.Uniplate

# Types

type BiplateType from to = from -> ([to], [to] -> from) #

Return all the top most children of type `to` within `from`.

If `from == to` then this function should return the root as the single child.

# Operations

## Queries

universeOn :: Uniplate to => BiplateType from to -> from -> [to] #

childrenOn :: Uniplate to => BiplateType from to -> from -> [to] #

Return the children of a type. If `to == from` then it returns the original element (in contrast to `children`)

## Transformations

transformOn :: Uniplate to => BiplateType from to -> (to -> to) -> from -> from #

transformOnM :: (Monad m, Uniplate to) => BiplateType from to -> (to -> m to) -> from -> m from #

rewriteOn :: Uniplate to => BiplateType from to -> (to -> Maybe to) -> from -> from #

rewriteOnM :: (Monad m, Uniplate to) => BiplateType from to -> (to -> m (Maybe to)) -> from -> m from #

descendOn :: Uniplate to => BiplateType from to -> (to -> to) -> from -> from #

descendOnM :: (Monad m, Uniplate to) => BiplateType from to -> (to -> m to) -> from -> m from #

## Other

holesOn :: Uniplate to => BiplateType from to -> from -> [(to, to -> from)] #

contextsOn :: Uniplate to => BiplateType from to -> from -> [(to, to -> from)] #

# Helper for writing instances

uniplateOnList :: BiplateType a b -> BiplateType [a] b #

Used for defining instances `UniplateFoo a => UniplateFoo [a]`