Library
Module
Module type
Parameter
Class
Class type
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.
make root
produces a forest with a single tree by using make
first forest
returns the first tree of the forest. This function is total since the module guarantees the forest is never empty.
val is_singleton : 'a t -> bool
is_singleton forest
returns true
if there is a single tree in the forest. false
otherwise.
seqnece tree forest
returns a new forest made of a sequence of forest, namely Seq.cons tree forest |> Seq.concat
.
map f forest
applies a function f
over each value of the forest.
map_tree f forest
applies a function f
over each tree of the forest.
val return : 'a -> 'a t
return v
returns a forest made of a single value.
bind forest f
is a generalisation of bind
over sequence of trees.
module Syntax : sig ... end
Monadic operators.