package bam

  1. Overview
  2. Docs

Module Tree.ForestSource

A forest can be considered as a non-empty sequence of trees. The functions declared in this module transposed naturally the functions provided on tree.

Function of this modules always ensure that the sequence is not empty. This is why the function sequence takes two arguments instead of one.

Because of the non-emptiness property, the function first is total.

Names of those functions are inspired from Haskell.

Sourcetype 'a t

Datatype for a forest.

Sourceval lift : 'a tree -> 'a t

lift tree returns a forest made of a single tree.

Sourceval make : 'a -> ('a -> 'a Seq.t) -> 'a t

make root produces a forest with a single tree by using make

Sourceval uncons : 'a t -> 'a tree * 'a tree Seq.t

uncons forest splits the forest into a tree and a sequence of trees.

Sourceval sequence : 'a t -> 'a t Seq.t -> 'a t

seqnece tree forest returns a new forest made of a sequence of forest, namely Seq.cons tree forest |> Seq.concat.

Sourceval map : ('a -> 'b) -> 'a t -> 'b t

map f forest applies a function f over each value of the forest.

Sourceval map_tree : ('a tree -> 'b tree) -> 'a t -> 'b t

map_tree f forest applies a function f over each tree of the forest.

Sourceval crunch : int -> 'a t -> 'a t

crunch i forest is the analogue of crunch

A monadic interface

Sourceval return : 'a -> 'a t

return v returns a forest made of a single value.

Sourceval bind : 'a t -> ('a -> 'b t) -> 'b t

bind forest f is a generalisation of bind over sequence of trees.

Sourcemodule Syntax : sig ... end

Monadic operators.

OCaml

Innovation. Community. Security.