Camlp4FoldGenerator

From Gallium

Jump to: navigation, search

The Camlp4 fold generator follow the same path than Camlp4MapGenerator that is more thoroughly described.

The difference with map is that fold returns the object itself as a threaded accumulator. A common style is to use functional objects of OCaml to carry information about the traversal using instance variables.

More roughly a method will make a case analysis on the argument and returns either self when nothing as to be done or {< acc = ...the new accumulator... >} to change the threaded value.

A complete example is given at Camlp4FoldGenerator Example.

Personal tools
Espace privé