Tools for building a tree from a string or a list of blocks. A tree is represented in text as an outline:
Example:
> data = "1\n 2\n 3\n 4\n5\n 6\n 7"
> fromString "?" identity data
Tree "0" [
Tree "1" [Tree "2" [],Tree "3" [], Tree "4" []]
, Tree "5" [Tree "6" [],Tree "7" []]
]The first argument of fromString is a label for a default node. The second argument, of type (String -> node), tells how to build a node from a string representation of that node. Here we use the representation of rose trees of elm/rose-tree.
Example:
> forestFromString "?" identity identity "1\n 2\n 3"
Ok [Tree "1" [Tree "2" [],Tree "3" []]]
> forestFromString "?" identity identity "1\n 2\n 3\n4\n 5\n 6"
Ok [Tree "1" [Tree "2" [],Tree "3" []],Tree "4" [Tree "5" [],Tree "6" []]]