Skip to main content Link Search Menu Expand Document (external link)

TreeNonLeaf overview

Internal (branching) node of a tree: a value of type A paired with a forest of child trees. Companion of {@link “./TreeLeaf.js” | MTreeLeaf}; both are unioned into {@link “./Tree.js” | MTree.Type}.

Quickstart

Example (Build a branch with two leaves)

import * as MTreeLeaf from "@parischap/effect-lib/Tree/TreeLeaf"
import * as MTreeNonLeaf from "@parischap/effect-lib/Tree/TreeNonLeaf"

const branch = MTreeNonLeaf.make({
  value: "root",
  forest: [MTreeLeaf.make("a"), MTreeLeaf.make("b")]
})
console.log(branch.value) // 'root'
console.log(branch.forest.length) // 2

Table of contents


Constructors

make

Builds a non-leaf node from value and forest.

Signature

export declare const make: <A, B>(params: MTypes.Data<Type<A, B>>) => Type<A, B>

Models

Type (class)

Internal node holding a value of type A and a forest of children of type MTreeForest.Type<A, B>.

Signature

export declare class Type<A, B> {
  private constructor({ value, forest }: MTypes.Data<Type<A, B>>)
}

make (static method)

Static constructor

Signature

static make<A, B>(params: MTypes.Data<Type<A, B>>): Type<A, B>

[MData.idSymbol] (method)

Returns the id of this

Signature

[MData.idSymbol](): string | (() => string)

forest (property)

The children of a NonLeaf

Signature

readonly forest: MTreeForest.Type<A, B>

Module markers

moduleTag

Module tag.

Signature

export declare const moduleTag: "@parischap/effect-lib/Tree/TreeNonLeaf/"