package plebeia

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Fold over a node

type 'a leave = {
  1. bud : 'a option -> Node_type.indexed -> Node_type.hashed -> 'a;
  2. extender : Segment.t -> 'a -> Node_type.indexed -> Node_type.hashed -> 'a;
  3. internal : 'a -> 'a -> Node_type.indexed -> Node_type.hashed -> 'a;
  4. leaf : Value.t -> Node_type.indexed -> Node_type.hashed -> 'a;
}
val default_leave_rebuild : Node_type.node leave
val fold : enter:(Node_type.t -> [< `Return of 'a | `Continue of Node_type.view ]) -> leave:'a leave -> Node_type.t -> 'a

Folding over a node with folding

When entering a node: node is executed with the current node. The function can stop the further traversal by returning `Return _ or continue the traversal by returning `Continue _.

When leaving a node after traversing its sub nodes: When enter returns `Continue _ and its subnodes are traversed, then leave is executed.

type 'a state

Interleaved folder state

val interleaved : enter:(Node_type.t -> [< `Return of 'a | `Continue of Node_type.view ]) -> leave:'a leave -> Node_type.t -> ('a state -> [> `Left of 'a state | `Right of 'a ]) * 'a state

Interleaved version of fold. Good to use with Lwt to achieve concurrency