Deconstruct the node and possibly empty forest of a tree. Useful in pipelines.
Underlying tree type.
The tree being deconstructed.
A pair of the tree node value and a possibly empty list of child trees.
import * as Tree from 'effect-tree'const tree = Tree.tree(1, [Tree.leaf(2), Tree.leaf(3)])const [value, forest] = Tree.destruct(tree)expect(value, 'value').toBe(1)expect(forest, 'forest').toEqual([Tree.leaf(2), Tree.leaf(3)]) Copy
import * as Tree from 'effect-tree'const tree = Tree.tree(1, [Tree.leaf(2), Tree.leaf(3)])const [value, forest] = Tree.destruct(tree)expect(value, 'value').toBe(1)expect(forest, 'forest').toEqual([Tree.leaf(2), Tree.leaf(3)])
Deconstruct the node and possibly empty forest of a tree. Useful in pipelines.