Run the given function over the given tree if it is a branch, else return the tree unchanged. This is like match where the onLeaf branch is set to identity.
onLeaf
identity
import * as Tree from 'effect-tree'const leaf = Tree.of(1)const branch = Tree.from(2, leaf)const changeBranch = Tree.modBranch(Tree.setValue(3))expect(changeBranch(leaf), 'leaf').toEqual(leaf)expect(changeBranch(branch), 'branch').toEqual(Tree.from(3, leaf)) Copy
import * as Tree from 'effect-tree'const leaf = Tree.of(1)const branch = Tree.from(2, leaf)const changeBranch = Tree.modBranch(Tree.setValue(3))expect(changeBranch(leaf), 'leaf').toEqual(leaf)expect(changeBranch(branch), 'branch').toEqual(Tree.from(3, leaf))
Underlying tree type.
Tree on which to run the given function.
A function from Branch to Tree.
The tree unchanged if it is a leaf, else the result of applying the given function on the branch.
Run the given function over the given tree if it is a branch, else return the tree unchanged. This is like match where the
onLeafbranch is set toidentity.Example
Type Param: A
Underlying tree type.
Param: self
Tree on which to run the given function.
Param: f
A function from Branch to Tree.
Returns
The tree unchanged if it is a leaf, else the result of applying the given function on the branch.