(.using
  [library
   [lux {"-" local}
    ["$" documentation {"+" documentation:}]
    [data
     [text {"+" \n}
      ["%" format {"+" format}]]]
    [macro
     ["[0]" template]]]]
  [\\library
   ["[0]" /]])

(documentation: (/.Thread ! it)
  "An imperative process with access to mutable values.")

(documentation: (/.Box ! it)
  "A mutable box holding a value.")

(documentation: /.box
  "A brand-new box initialized to the given value."
  [(box init)])

(documentation: /.read!
  "Reads the current value in the box."
  [(read! box)])

(documentation: /.write!
  "Mutates the value in the box."
  [(write! value box)])

(documentation: /.result
  "Executes the imperative thread in a self-contained way."
  [(result thread)])

(documentation: /.io
  "Transforms the imperative thread into an I/O computation.")

(documentation: /.update!
  "Update a box's value by applying a function to it."
  [(update! f box)])

(.def: .public documentation
  (.List $.Module)
  ($.module /._
            ""
            [..Thread
             ..Box
             ..box
             ..read!
             ..write!
             ..result
             ..io
             ..update!
             ($.default /.functor)
             ($.default /.apply)
             ($.default /.monad)]
            []))
