A module for printing a tree to a terminal like the 'tree' command

Today I made a module for printing trees in a readable fashion. The output looks like the output of the tree command:

image

It works on any data structure that supports get_name and get_children functions and depends on nothing else than the OCaml standard library.

I’m releasing it into the Public Domain in the hope others find it useful. Anyone is welcome to include it in their projects or turn it into a proper open-source project that they maintain.

8 Likes

This is pretty nice. It could be added to
printbox maybe :slight_smile:

3 Likes

I tried this(your module for printing trees) on a binary tree and a trie like data structure and both worked great.

1 Like