Module type Ptree.S

Structures whose tensor leaves can be traversed.

Implementations must satisfy:

  • map f t applies f to every tensor leaf of t exactly once and preserves the structure of t.
  • map2 f a b applies f to corresponding leaves of a and b, which must be structurally equal.
  • iter f t applies f to every tensor leaf of t exactly once, in a stable order.
type t

The structure type.

val map : ('a 'b. ('a, 'b) Nx_effect.t -> ('a, 'b) Nx_effect.t) -> t -> t

map f t is t with f applied to every tensor leaf.

val map2 : ('a 'b. ('a, 'b) Nx_effect.t -> ('a, 'b) Nx_effect.t -> ('a, 'b) Nx_effect.t) -> t -> t -> t

map2 f a b is a and b combined leafwise with f.

Raises Invalid_argument if a and b are not structurally equal.

val iter : ('a 'b. ('a, 'b) Nx_effect.t -> unit) -> t -> unit

iter f t applies f to every tensor leaf of t.