(.require
 [library
  [lux (.except)
   ["$" documentation]
   [data
    [text (.only \n)
     ["%" \\format (.only format)]]]]]
 [\\library
  ["[0]" /]])

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

        ($.definition /.read)
        ($.definition /.write)
        ($.definition /.functor)
        ($.definition /.apply)
        ($.definition /.monad)

        ($.definition (/.Var it)
          "A mutable cell containing a value, and observers that will be alerted of any change to it.")

        ($.definition /.var
          "Creates a new STM var, with a default value."
          [(var value)])

        ($.definition /.changes
          "Creates a channel that will receive all changes to the value of the given var."
          [(changes target)])

        ($.definition (/.STM it)
          "A computation which updates a transaction and produces a value.")

        ($.definition /.update
          "Update a var's value, and return a tuple with the old and the new values."
          [(update function var)])

        ($.definition /.commit!
          (format "Commits a transaction and returns its result (asynchronously)."
                  \n "Note that a transaction may be re-run an indeterminate number of times if other transactions involving the same variables successfully commit first."
                  \n "For this reason, it's important to note that transactions must be free from side-effects, such as I/O.")
          [(commit! procedure)])
        ))
