module Generic_fun_uniplate:sig..end
It is inspired by the Haskell uniplate by Neil Mitchell.
The function names, implementation and many comments are taken from Traversal implementation by Sebastian Fischer, and are the same as in the
Generic_fun_multiplate generalisation.val scrap : 'a Ty.T.ty -> 'a -> 'a list * ('a list -> 'a)Scrap a returns the list of children of type a of a value of type a
and a function to replace the children. That function should be given a list of the same size
as the children list.
x == let (children, replace) = scrap a b x in replace children
val children : 'a Ty.T.ty -> 'a -> 'a lista of a value of type aval replace_children : 'a Ty.T.ty -> 'a -> 'a list -> 'a
(Alternative specification: additional children are ignored,
and if not enough are given, only the first ones are changed)
val map_children : 'a Ty.T.ty -> ('a -> 'a) -> 'a -> 'aval family : 'a Ty.T.ty -> 'a -> 'a listfamily builds a pre-order family where the value is listed before its descendentsval post_family : 'a Ty.T.ty -> 'a -> 'a listGeneric_fun_uniplate.post_family lists the descendents in post-order: the leaves are first and the root is lastval map_family : 'a Ty.T.ty -> ('a -> 'a) -> 'a -> 'aval reduce_family : 'a Ty.T.ty -> ('a -> 'a option) -> 'a -> 'areduce_family returns a function that exhaustively
transforms the family of the input. The traversal proceeds
bottom-up, first transforming the families of the
children. If a transformation succeeds then the result is
re-reduce_family-ed.
A post-condition is that the input function returns
None on all family members of the output.
val para : 'a Ty.T.ty -> ('a -> 'r list -> 'r) -> 'a -> 'rval traverse_children : 'f Applicative.T.applicative ->
'a Ty.T.ty ->
('a -> ('a, 'f) App.T.app) ->
'a -> ('a, 'f) App.T.appGeneric_fun_uniplate.map_childrenval traverse_family : 'f Monad.T.monad ->
'a Ty.T.ty ->
('a -> ('a, 'f) App.T.app) ->
'a -> ('a, 'f) App.T.appGeneric_fun_uniplate.map_familyval mreduce_family : 'f Monad.T.monad ->
'a Ty.T.ty ->
('a -> ('a option, 'f) App.T.app) ->
'a -> ('a, 'f) App.T.appGeneric_fun_uniplate.reduce_family