(.require
 [library
  [lux (.except)
   ["$" documentation]
   [data
    ["[0]" text (.only \n)
     ["%" \\format (.only format)]]
    [collection
     ["[0]" list (.use "[1]#[0]" monoid)]]]]]
 ["[0]" \\parser]
 [\\library
  ["[0]" /]]
 ["[0]" /
  ["[1][0]" finger]
  ["[1][0]" zipper]])

(`` (def \\parser
      (List $.Documentation)
      (list ($.module \\parser._
                      "")

            ($.definition \\parser.cannot_move_further)

            ($.definition (\\parser.Parser it)
              "A parser of arbitrary trees.")

            ($.definition \\parser.result'
              "Applies the parser against a tree zipper."
              [(result' parser zipper)])

            ($.definition \\parser.result
              "Applies the parser against a tree."
              [(result parser tree)])

            ($.definition \\parser.value
              "Yields the value inside the current tree node.")

            (,, (with_template [<name> <doc>]
                  [($.definition <name>
                     <doc>)]

                  [\\parser.down "Move down."]
                  [\\parser.up "Move up."]

                  [\\parser.right "Move to the right."]
                  [\\parser.rightmost "Move to the rightmost node."]

                  [\\parser.left "Move to the left."]
                  [\\parser.leftmost "Move to the leftmost node."]
                  
                  [\\parser.next "Move to the next node."]
                  [\\parser.end "Move to the last node."]
                  
                  [\\parser.previous "Move to the previous node."]
                  [\\parser.start "Move to the root node."]
                  ))
            )))

(.def .public documentation
  (List $.Documentation)
  (list.partial ($.module /._
                          "")

                ($.definition /.equivalence)
                ($.definition /.functor)
                ($.definition /.mix)

                ($.definition (/.Tree it)
                  "A generic tree data-structure.")

                ($.definition /.flat
                  "All the leaf values of the tree, in order."
                  [(flat tree)])

                ($.definition /.leaf
                  ""
                  [(leaf value)])

                ($.definition /.branch
                  ""
                  [(branch value children)])

                ($.definition /.tree
                  "Tree literals."
                  [(is (Tree Nat)
                       (tree 12
                             {34 {}
                                 56 {}
                                 78 {90 {}}}))])

                (all list#composite
                     ..\\parser
                     /finger.documentation
                     /zipper.documentation
                     )
                ))
