github ↗
docs menu

Module Ptree.Path

Paths from a value's root to one of its parts.

#type seg =
  1. #| Field of string
    (*

    A named part, such as a record's field.

    *)
  2. #| Index of int
    (*

    A numbered part: a list's or array's element, a tuple's component, a pair's side.

    *)

The type for a path's steps.

#type t

The type for paths. Some and a variant's case add no step.

#val root : t

root is the path of no step.

#val v : seg list -> t

v segs is the path of segs, from the root.

#val add : seg -> t -> t

add seg p is p then seg, in constant time, sharing p.

#val segments : t -> seg list

segments p is p's steps, from the root.

#val equal : t -> t -> bool

equal p q is true iff p and q have equal steps: the one field "a.b" and the field a then b differ, though they print alike.

#val to_string : t -> string

to_string p is p's steps joined by ".", as "blocks.3.fc.b": the name of the part at p in a saved value. The root is "".

#val pp : Stdlib.Format.formatter -> t -> unit

pp formats a path as to_string.