effect-tree - v1.0.36
    Preparing search index...

    Examples

    Has containers ready to run the examples.

    You can run the examples locally. For example to run the basic example clone this repository, and launch the example:

    git clone git@github.com:middle-ages/effect-tree.git
    cd effect-tree
    pnpm i
    pnpm run:example draw

    # Run with no parameters to get a list of examples
    pnpm run:example

    # This should work the same
    pnpm tsx examples/draw.ts

    The expected terminal output of each example appears inline with the source code.

    Example Note
    basic Create a tree, add/remove nodes, and other basic use-cases.
    codecs Encode/decode the same tree through all codecs.
    directory-tree Read directories into trees and write directories from trees.
    draw Draw trees in various themes.
    fibonacci A fold and an unfold all about the Fibonacci sequence.
    folds Fusing folds into tuples and structs.
    genealogy Level labels, bottom grounded subtrees, and encoding to indented strings.
    generate Enumerate and generate trees.
    layout Alternate tree layouts using the Draw module.
    nary N-ary trees: trees with a fixed degree.
    unfolds Unfold a tree from functions.
    zipper Use a zipper to navigate and change trees.

    Running pnpm repl (or tsx dev/repl.ts) will run the Node.js REPL with symbols useful for quick experimentation added to the global scope.

    Type help for more info. You should see this:

    > tsx --import=./dev/repl.ts
    » Loaded “dev/repl.ts”.
    
    • .help............Node.js help
    • help.............this help message
    • _................previous result
    • demoTree.........a small tree of strings
    • getValue(tree)...get root node value
    • draw(tree).......draw string or numeric tree to console
    • of('hello')......create leaf from value
    • from(............create tree from value and possibly empty tree list
           'root',
           of('leaf₁'),                               •┬─root
           from('branch', of('leaf₂'), of('leaf₃')) ┄→ ├───leaf₁
          )      ┊    ┊  ┊                        ┊    └─┬─branch
                 ╰┄┬┄┄╯  ╰┄┄┄┄┄┄┄┄┄┄┬┄┄┄┄┄┄┄┄┄┄┄┄┄╯      └─┬─leaf₂
      branch value┄╯                ╰┄list of leaves       └─leaf₃
    
    Try: > draw(demoTree)                  Global namespace:
         > pipe(8, binaryTree, draw)       ‣ effect exports under “effect”
                                           ‣ effect/Function exports
                                           ‣ effect-tree exports
    
    Welcome to Node.js v22.14.0.
    Type ".help" for more information.
    >
    

    Here is a screenshot of REPL run:

    REPL Run