github ↗
docs menu

Module type Ptree.S

Structures.

walk c x walks every part of x once and rebuilds x from what each walk returns:

  • each position of the parameter with Walk.leaf, each fixed array with Walk.tensor, and each sub-structure with its own walk;
  • each integer that changes what a program computes (a window, a block shape, a layer kind) is reported with Walk.int; other scalar data a program depends on belongs in an array;
  • a variant reports its case with Walk.case before its case's other parts, with a tag no other case of the type uses;
  • options and lists are walked with Walk.option and Walk.list, which report presence and length, so a part with no array still counts;
  • a dictionary reports its size with Walk.int and each key with Walk.case before walking the key's value with Walk.field;
  • a walk that returns each part unchanged rebuilds an equal value.

The type checker ensures no position of the parameter is forgotten, since Walk.leaf changes its type. A forgotten fixed array, integer or case compiles; a test of the structure's visits catches it.

A record literal evaluates its fields in an order OCaml leaves unspecified, and every operation runs the same walk: write the fields as a sequence of lets where the order must show.

'd is the set of the fixed arrays: a structure whose every array is at its parameter ignores it, as type ('a, _) t = 'a linear.

#type ('a, 'd) t

The type for values with parameter 'a and fixed arrays on 'd.

#val walk : ('a, 'b, 'd, 'e) Walk.cursor -> ('a, 'd) t -> ('b, 'e) t

walk c x walks every part of x with c and is x rebuilt from what the walks return.